Optimized log storage for asynchronous log updates

ABSTRACT

A log-structured data store may implement optimized log storage for asynchronous log updates. In some embodiments, log records may be received indicating updates to data stored for a storage client and indicating positions in a log record sequence. The log records themselves may not be guaranteed to be received according to the log record sequence. Received log records may be stored in a hot log portion of a block-based storage device according to an order in which they are received. Log records in the hot log portion may then be identified to be moved to a cold log portion of the block-based storage device in order to complete a next portion of the log record sequence. Log records may be modified, such as compressed, or coalesced, before being stored together in a data block of the cold log portion according to the log record sequence.

This application is a continuation of U.S. patent application Ser. No.14/094,154, filed Dec. 2, 2013, now U.S. Pat. No. 9,223,843, which ishereby incorporated by reference herein in its entirety.

BACKGROUND

Log-structured storage developed in order to provide a more efficientmeans for storing data in persistent storage devices. Data and metadatachanges are sequentially recorded as log records in a log structurereducing the number of operations to persist the data and metadatachanges. For systems that frequently add and/or modify data, such asdatabase systems, log-structured storage reduces the latency forrecording new data as well as modifying data already stored. Log recordsare typically stored in storage according to a log record sequence sothat log records that are dependent upon prior log records may beprocessed in a correct order.

Situating log-structured storage systems in a distributed systemarchitecture may introduce various complications that blunt theefficiency of log-structured storage. For example, distributed storagesystems may have to ensure consistency across multiple systems ordevices. Various different schemes may be employed to ensureconsistency. However, ensuring consistency may increase the cost and/ortime to record new log records at the log-structured storage. Forexample, synchronous approaches may require that each log record bepersisted in the distributed storage system and acknowledged back to astorage client before a next log record may be sent to be recorded.Alternatively, asynchronous approaches may allow for other log recordsto be sent and recorded while prior log records have not yet beenrecorded. While changes to a log processed synchronously may be easilyordered when received at a storage node of a log-structured distributedstorage system if ordered according to the log record sequence,asynchronous updates may prove more challenging. Acknowledgments of logrecords may be delayed until prior log records are received, or logrecords may be stored out of order, which burdens the storage node whenit is time to perform various operations dependent on the ordering oflog records.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating optimized log storage forasynchronous log updates, according to some embodiments.

FIG. 2 is a block diagram illustrating a service system architecturethat may be configured to implement a network-based database service anda network-based distributed storage service, according to someembodiments.

FIG. 3 is a block diagram illustrating various components of a databasesystem that includes a database engine and a separate distributedstorage service, according to some embodiments.

FIG. 4 is a block diagram illustrating a distributed storage system,according to some embodiments.

FIGS. 5A and 5B are block diagrams illustrating the use of a separatedistributed storage system in a database system, according to someembodiments.

FIG. 6 is a block diagram illustrating how data and metadata may bestored on a storage node of a distributed storage system, according tosome embodiments.

FIG. 7 is a block flow diagram illustrating optimized log storage at adistributed storage system, according to some embodiments

FIG. 8 is a block diagram illustrating an example configuration of adatabase volume, according to some embodiments.

FIG. 9 is a high-level flowchart illustrating methods and techniques toimplement optimized log storage for asynchronous log updates, accordingto some embodiments.

FIG. 10 is a high-level flowchart illustrating methods and techniques tomodify log records prior to cold log storage, according to someembodiments.

FIG. 11 is a high-level flowchart of efficient log record replicationacross storage nodes using optimized log storage, according to someembodiments.

FIG. 12 is an example computer system, according to various embodiments.

While embodiments are described herein by way of example for severalembodiments and illustrative drawings, those skilled in the art willrecognize that the embodiments are not limited to the embodiments ordrawings described. It should be understood, that the drawings anddetailed description thereto are not intended to limit embodiments tothe particular form disclosed, but on the contrary, the intention is tocover all modifications, equivalents and alternatives falling within thespirit and scope as defined by the appended claims. The headings usedherein are for organizational purposes only and are not meant to be usedto limit the scope of the description or the claims. As used throughoutthis application, the word “may” is used in a permissive sense (i.e.,meaning having the potential to), rather than the mandatory sense (i.e.,meaning must). The words “include,” “including,” and “includes” indicateopen-ended relationships and therefore mean including, but not limitedto. Similarly, the words “have,” “having,” and “has” also indicateopen-ended relationships, and thus mean having, but not limited to. Theterms “first,” “second,” “third,” and so forth as used herein are usedas labels for nouns that they precede, and do not imply any type ofordering (e.g., spatial, temporal, logical, etc.) unless such anordering is otherwise explicitly indicated.

Various components may be described as “configured to” perform a task ortasks. In such contexts, “configured to” is a broad recitation generallymeaning “having structure that” performs the task or tasks duringoperation. As such, the component can be configured to perform the taskeven when the component is not currently performing that task (e.g., acomputer system may be configured to perform operations even when theoperations are not currently being performed). In some contexts,“configured to” may be a broad recitation of structure generally meaning“having circuitry that” performs the task or tasks during operation. Assuch, the component can be configured to perform the task even when thecomponent is not currently on. In general, the circuitry that forms thestructure corresponding to “configured to” may include hardwarecircuits.

Various components may be described as performing a task or tasks, forconvenience in the description. Such descriptions should be interpretedas including the phrase “configured to.” Reciting a component that isconfigured to perform one or more tasks is expressly intended not toinvoke 35 U.S.C. § 112, paragraph six, interpretation for thatcomponent.

“Based On.” As used herein, this term is used to describe one or morefactors that affect a determination. This term does not forecloseadditional factors that may affect a determination. That is, adetermination may be solely based on those factors or based, at least inpart, on those factors. Consider the phrase “determine A based on B.”While B may be a factor that affects the determination of A, such aphrase does not foreclose the determination of A from also being basedon C. In other instances, A may be determined based solely on B.

The scope of the present disclosure includes any feature or combinationof features disclosed herein (either explicitly or implicitly), or anygeneralization thereof, whether or not it mitigates any or all of theproblems addressed herein. Accordingly, new claims may be formulatedduring prosecution of this application (or an application claimingpriority thereto) to any such combination of features. In particular,with reference to the appended claims, features from dependent claimsmay be combined with those of the independent claims and features fromrespective independent claims may be combined in any appropriate mannerand not merely in the specific combinations enumerated in the appendedclaims.

DETAILED DESCRIPTION

Various embodiments of optimized log storage for asynchronous logupdates are described herein. Log records may be received indicatingchanges to data or metadata maintained as part of a log-structured datastore. Log records may be, in some embodiments, ordered according to alog record sequence. For example, each log record may be assigned aunique Log Sequence Number (LSN), which indicates that log record'sposition in the log record sequence. A log-structured data store mayimplement a hot log portion of the block-based storage device to storelog records as they are received, and a cold log portion of theblock-based storage device to stored log records in data blocks (or ingroups of data blocks, such as pages) according to the log recordsequence. As log records may be sent to log-structured storage, stored,and acknowledged asynchronously, log records are not guaranteed toarrive in the log record sequence order. However, once log records aremoved from the hot log to cold log portion the log records may be storedaccording to the log record sequence as each data block in the cold logstorage may maintain a group of log records within a range of the logrecord sequence that are not maintained in any other blocks (e.g., LSNs1-20). In at least some embodiments, the log records in a data block maybe stored sequentially.

FIG. 1 is a block diagram illustrating optimized log storage forasynchronous log updates, according to some embodiments. Alog-structured distributed storage system 100 may store data for aclient in a log-structured data store. Clients, such as storage client104, may be any type of application, device, or system (e.g., computingsystem 1200 discussed below with regard to FIG. 12) that may beconfigured to communicate with or access data stored at log-structureddistributed storage system 100. Log-structured distributed storagesystem 100 may, in some embodiments, implement multiple storage nodes108 to store data for storage client 104. Storage node(s) 108 may beimplemented as virtual instances, servers, or other systems, such ascomputing system 1200 described below with regard to FIG. 12. Eachstorage node 108 may implement a respective log-structured data storefor client data. Storage node(s) 108 may stand alone, or groupedtogether to perform a protection group of storage nodes, such asdescribed below with regard to FIGS. 3-8. In some embodiments, membersof the protection group for client data may each maintain a respectiveversion of the same data for storage client 104. In some embodimentsblock-based storage device(s) 106, such as one or more of variousblock-based persistent storage devices (e.g., hard disk drives, solidstates drives, etc.), may be accessible to storage node(s) 108. A datablock of block-based storage device(s) 106 may be a logical range of ablock-based storage device storing a range of data (e.g., a multiple of2 or more bits).

As illustrated in FIG. 1, log records 102 may be received at storagenode(s) 108 and stored 110 in a hot log portion 120 of block-basedstorage devices. Log records may be stored in free or available datablocks (or data pages) of block-based storage device(s) 106 in the hotlog portion 120 as they are received, in some embodiments. Log recordsmay not be guaranteed to arrive and/or be stored in the hot log portion120 according to the log record sequence (and/or the sequence in whichthey are sent). For example, log record 102 r may come in the log recordsequence after log records 102 p, 102 q, 102 o, 102 n, and 102 m, andyet may be the first stored or received in hot log portion 120. In atleast some embodiments, log records, such as 102 r, 102 p, 102 q, 102 o,102 n, 102 s, and 102 m, may each be acknowledged back to storage client104 when received. A hot log index structure may be updated to reflectthe current contents of hot log 120. If log records are identified asgarbage collectible, and thus not to be moved to cold log 140, variousindicators may be updated in the hot log index structure to identifygarbage collectible log records in the hot log.

In various embodiments, log records may be identified to be moved to thecold log portion 140 of block-based storage device(s) 106. These logrecords may complete a next portion of the log record sequence that isnot currently stored in cold log storage 140. For example, FIG. 1illustrates that log records 102 m, 102 n, 102 o, and 102 p may be thenext 4 log records in the log record sequence not stored in cold logstorage (as the log record sequence in cold log storage currently endsat 102 l). These identified log records may then be read from hot log120 and stored 130 together into a data block in cold log 140. In someembodiments, log records identified for storage may be modified togenerate modified versions of the log records that are then stored incold log 140. For example, if log records linked in a dependency chainexceed a coalesce threshold, then the log records may be coalesced intoa single log record including the effects of the updates from the readlog records. In another example, log records may each be compressed togenerate compressed versions of log records to be stored in cold log140.

As noted above, log records in cold log 140 may be stored according tothe log record sequence, as may be indicated by LSNs. For example, FIG.1 illustrates that log records 102 a, 102 b, 102 c, and 102 d, arestored in order in data block 146, while log records 102 e, 102 f, 102g, and 102 h, are stored together in data block 144. Similarly, logrecords 102 i, 102 j, 102 k, and 102 l, are stored together in order indata block 142. Log records stored in sequential order may beefficiently index in a cold log index, such as by maintaining a singlelog record position entry sufficient to indicate positions of the logrecords of a data block in the log record sequence, and efficientlysearched, such as by a binary search algorithm.

Cold log storage may be optimized to perform various differentoperations for the log-structured data stored. Efficient replication oflog records among protection group members, such as discussed below withregard to FIGS. 5B and 11 may be implemented. In another example,efficient garbage collection of log records from cold log storage mayalso be implemented, as discussed below with regard to FIG. 7.

Please note, FIG. 1 is provided as a logical illustration of optimizedlog storage for asynchronous log updates, and is not intended to belimiting as to the physical arrangement, size, or number of components,modules, or devices, implementing a log-structured data store. Forexample, data blocks may hold varying sizes and/or numbers of logrecords.

The specification first describes an example of a log-structured datastore implemented as a distributed storage service that implementsoptimized log storage for asynchronous log updates. The distributedstorage service may store data for many different types of clients, invarious embodiments. One such client may be a network-based databaseservice, describe in further detail below. Included in the descriptionof the example network-based database service are various aspects of theexample network-based database service along with the variousinteractions between the database service and the distributed storageservice. The specification then describes a flowchart of variousembodiments of methods for implementing optimized log storage forasynchronous log updates. Next, the specification describes an examplesystem that may implement the disclosed techniques. Various examples areprovided throughout the specification.

The systems described herein may, in some embodiments, implement anetwork-based service that enables clients (e.g., subscribers) tooperate a data storage system in a cloud computing environment. In someembodiments, the data storage system may be an enterprise-class databasesystem that is highly scalable and extensible. In some embodiments,queries may be directed to database storage that is distributed acrossmultiple physical resources, and the database system may be scaled up ordown on an as needed basis. The database system may work effectivelywith database schemas of various types and/or organizations, indifferent embodiments. In some embodiments, clients/subscribers maysubmit queries in a number of ways, e.g., interactively via an SQLinterface to the database system. In other embodiments, externalapplications and programs may submit queries using Open DatabaseConnectivity (ODBC) and/or Java Database Connectivity (JDBC) driverinterfaces to the database system.

More specifically, the systems described herein may, in someembodiments, implement a service-oriented architecture in which variousfunctional components of a single database system are intrinsicallydistributed. For example, rather than lashing together multiple completeand monolithic database instances (each of which may include extraneousfunctionality, such as an application server, search functionality, orother functionality beyond that required to provide the core functionsof a database), these systems may organize the basic operations of adatabase (e.g., query processing, transaction management, caching andstorage) into tiers that may be individually and independently scalable.For example, in some embodiments, each database instance in the systemsdescribed herein may include a database tier (which may include a singledatabase engine head node and a client-side storage system driver), anda separate, distributed storage system (which may include multiplestorage nodes that collectively perform some of the operationstraditionally performed in the database tier of existing systems).

As described in more detail herein, in some embodiments, some of thelowest level operations of a database, (e.g., backup, restore, snapshot,recovery, log record manipulation, and/or various space managementoperations) may be offloaded from the database engine to the storagelayer (or tier), such as a distributed storage system, and distributedacross multiple nodes and storage devices. For example, in someembodiments, rather than the database engine applying changes to adatabase (or data pages thereof) and then sending the modified datapages to the storage layer, the application of changes to the storeddatabase (and data pages thereof) may be the responsibility of thestorage layer itself. In such embodiments, redo log records, rather thanmodified data pages, may be sent to the storage layer, after which redoprocessing (e.g., the application of the redo log records) may beperformed somewhat lazily and in a distributed manner (e.g., by abackground process). In some embodiments, crash recovery (e.g., therebuilding of data pages from stored redo log records) may also beperformed by the storage layer and may also be performed by adistributed (and, in some cases, lazy) background process.

In some embodiments, because only redo logs (and not modified datapages) are sent to the storage layer, there may be much less networktraffic between the database tier and the storage layer than in existingdatabase systems. In some embodiments, each redo log may be on the orderof one-tenth the size of the corresponding data page for which itspecifies a change. Note that requests sent from the database tier andthe distributed storage system may be asynchronous and that multiplesuch requests may be in flight at a time.

In general, after being given a piece of data, a primary requirement ofa database is that it can eventually give that piece of data back. To dothis, the database may include several different components (or tiers),each of which performs a different function. For example, a traditionaldatabase may be thought of as having three tiers: a first tier forperforming query parsing, optimization and execution; a second tier forproviding transactionality, recovery, and durability; and a third tierthat provides storage, either on locally attached disks or onnetwork-attached storage. As noted above, previous attempts to scale atraditional database have typically involved replicating all three tiersof the database and distributing those replicated database instancesacross multiple machines.

In some embodiments, the systems described herein may partitionfunctionality of a database system differently than in a traditionaldatabase, and may distribute only a subset of the functional components(rather than a complete database instance) across multiple machines inorder to implement scaling. For example, in some embodiments, aclient-facing tier may be configured to receive a request specifyingwhat data is to be stored or retrieved, but not how to store or retrievethe data. This tier may perform request parsing and/or optimization(e.g., SQL parsing and optimization), while another tier may beresponsible for query execution. In some embodiments, a third tier maybe responsible for providing transactionality and consistency ofresults. For example, this tier may be configured to enforce some of theso-called ACID properties, in particular, the Atomicity of transactionsthat target the database, maintaining Consistency within the database,and ensuring Isolation between the transactions that target thedatabase. In some embodiments, a fourth tier may then be responsible forproviding Durability of the stored data in the presence of various sortsof faults. For example, this tier may be responsible for change logging,recovery from a database crash, managing access to the underlyingstorage volumes and/or space management in the underlying storagevolumes.

In various embodiments, a database instance may include multiplefunctional components (or layers), each of which provides a portion ofthe functionality of the database instance. In one such example, adatabase instance may include a query parsing and query optimizationlayer, a query execution layer, a transactionality and consistencymanagement layer, and a durability and space management layer. As notedabove, in some existing database systems, scaling a database instancemay involve duplicating the entire database instance one or more times(including all of the example layers), and then adding glue logic tostitch them together. In some embodiments, the systems described hereinmay instead offload the functionality of durability and space managementlayer from the database tier to a separate storage layer, and maydistribute that functionality across multiple storage nodes in thestorage layer.

In some embodiments, the database systems described herein may retainmuch of the structure of the upper half of the database instance, suchas query parsing and query optimization layer, a query execution layer,and a transactionality and consistency management layer, but mayredistribute responsibility for at least portions of the backup,restore, snapshot, recovery, and/or various space management operationsto the storage tier. Redistributing functionality in this manner andtightly coupling log processing between the database tier and thestorage tier may improve performance, increase availability and reducecosts, when compared to previous approaches to providing a scalabledatabase. For example, network and input/output bandwidth requirementsmay be reduced, since only redo log records (which are much smaller insize than the actual data pages) may be shipped across nodes orpersisted within the latency path of write operations. In addition, thegeneration of data pages can be done independently in the background oneach storage node (as foreground processing allows), without blockingincoming write operations. In some embodiments, the use oflog-structured, non-overwrite storage may allow backup, restore,snapshots, point-in-time recovery, and volume growth operations to beperformed more efficiently, e.g., by using metadata manipulation ratherthan movement or copying of a data page. In some embodiments, thestorage layer may also assume the responsibility for the replication ofdata stored on behalf of clients (and/or metadata associated with thatdata, such as redo log records) across multiple storage nodes. Forexample, data (and/or metadata) may be replicated locally (e.g., withina single “availability zone” in which a collection of storage nodesexecutes on its own physically distinct, independent infrastructure)and/or across availability zones in a single region or in differentregions.

In various embodiments, the database systems described herein maysupport a standard or custom application programming interface (API) fora variety of database operations. For example, the API may supportoperations for creating a database, creating a table, altering a table,creating a user, dropping a user, inserting one or more rows in a table,copying values, selecting data from within a table (e.g., querying atable), canceling or aborting a query, creating a snapshot, and/or otheroperations.

In some embodiments, the database tier of a database instance mayinclude a database engine head node server that receives read and/orwrite requests from various client programs (e.g., applications) and/orsubscribers (users), then parses them and develops an execution plan tocarry out the associated database operation(s). For example, thedatabase engine head node may develop the series of steps necessary toobtain results for complex queries and joins. In some embodiments, thedatabase engine head node may manage communications between the databasetier of the database system and clients/subscribers, as well ascommunications between the database tier and a separate distributedstorage system.

In some embodiments, the database engine head node may be responsiblefor receiving SQL requests from end clients through a JDBC or ODBCinterface and for performing SQL processing and transaction management(which may include locking) locally. However, rather than generatingdata pages locally, the database engine head node (or various componentsthereof) may generate redo log records and may ship them to theappropriate nodes of a separate distributed storage system. In someembodiments, a client-side driver for the distributed storage system maybe hosted on the database engine head node and may be responsible forrouting redo log records to the storage system node (or nodes) thatstore the segments (or data pages thereof) to which those redo logrecords are directed. For example, in some embodiments, each segment maybe mirrored (or otherwise made durable) on multiple storage system nodesthat form a protection group. In such embodiments, the client-sidedriver may keep track of the nodes on which each segment is stored andmay route redo logs to all of the nodes on which a segment is stored(e.g., asynchronously and in parallel, at substantially the same time),when a client request is received. As soon as the client-side driverreceives an acknowledgement back from a write quorum of the storagenodes in the protection group (which may indicate that the redo logrecord has been written to the storage node), it may send anacknowledgement of the requested change to the database tier (e.g., tothe database engine head node). For example, in embodiments in whichdata is made durable through the use of protection groups, the databaseengine head node may not be able to commit a transaction until andunless the client-side driver receives a reply from enough storage nodeinstances to constitute a write quorum. Similarly, for a read requestdirected to a particular segment, the client-side driver may route theread request to all of the nodes on which the segment is stored (e.g.,asynchronously and in parallel, at substantially the same time). As soonas the client-side driver receives the requested data from a read quorumof the storage nodes in the protection group, it may return therequested data to the database tier (e.g., to the database engine headnode).

In some embodiments, the database tier (or more specifically, thedatabase engine head node) may include a cache in which recentlyaccessed data pages are held temporarily. In such embodiments, if awrite request is received that targets a data page held in such a cache,in addition to shipping a corresponding redo log record to the storagelayer, the database engine may apply the change to the copy of the datapage held in its cache. However, unlike in other database systems, adata page held in this cache may not ever be flushed to the storagelayer, and it may be discarded at any time (e.g., at any time after theredo log record for a write request that was most recently applied tothe cached copy has been sent to the storage layer and acknowledged).The cache may implement any of various locking mechanisms to controlaccess to the cache by at most one writer (or multiple readers) at atime, in different embodiments. Note, however, that in embodiments thatinclude such a cache, the cache may not be distributed across multiplenodes, but may exist only on the database engine head node for a givendatabase instance. Therefore, there may be no cache coherency orconsistency issues to manage.

In some embodiments, the database tier may support the use ofsynchronous or asynchronous read replicas in the system, e.g., read-onlycopies of data on different nodes of the database tier to which readrequests can be routed. In such embodiments, if the database engine headnode for a given database receives a read request directed to aparticular data page, it may route the request to any one (or aparticular one) of these read-only copies. In some embodiments, theclient-side driver in the database engine head node may be configured tonotify these other nodes about updates and/or invalidations to cacheddata pages (e.g., in order to prompt them to invalidate their caches,after which they may request updated copies of updated data pages fromthe storage layer).

In some embodiments, the client-side driver running on the databaseengine head node may expose a private interface to the storage tier. Insome embodiments, it may also expose a traditional iSCSI interface toone or more other components (e.g., other database engines or virtualcomputing services components). In some embodiments, storage for adatabase instance in the storage tier may be modeled as a single volumethat can grow in size without limits, and that can have an unlimitednumber of IOPS associated with it. When a volume is created, it may becreated with a specific size, with a specific availability/durabilitycharacteristic (e.g., specifying how it is replicated), and/or with anIOPS rate associated with it (e.g., both peak and sustained). Forexample, in some embodiments, a variety of different durability modelsmay be supported, and users/subscribers may be able to specify, fortheir database, a number of replication copies, zones, or regions and/orwhether replication is synchronous or asynchronous based upon theirdurability, performance and cost objectives.

In some embodiments, the client side driver may maintain metadata aboutthe volume and may directly send asynchronous requests to each of thestorage nodes necessary to fulfill read requests and write requestswithout requiring additional hops between storage nodes. For example, insome embodiments, in response to a request to make a change to adatabase, the client-side driver may be configured to determine the oneor more nodes that are implementing the storage for the targeted datapage, and to route the redo log record(s) specifying that change tothose storage nodes. The storage nodes may then be responsible forapplying the change specified in the redo log record to the targeteddata page at some point in the future. As writes are acknowledged backto the client-side driver, the client-side driver may advance the pointat which the volume is durable and may acknowledge commits back to thedatabase tier. As previously noted, in some embodiments, the client-sidedriver may not ever send data pages to the storage node servers. Thismay not only reduce network traffic, but may also remove the need forthe checkpoint or background writer threads that constrainforeground-processing throughput in previous database systems.

In some embodiments, many read requests may be served by the databaseengine head node cache. However, write requests may require durability,since large-scale failure events may be too common to allow onlyin-memory replication. Therefore, the systems described herein may beconfigured to minimize the cost of the redo log record write operationsthat are in the foreground latency path by implementing data storage inthe storage tier as two regions: a small append-only log-structuredregion into which redo log records are written when they are receivedfrom the database tier, and a larger region in which log records arecoalesced together to create new versions of data pages in thebackground. In some embodiments, an in-memory structure may bemaintained for each data page that points to the last redo log recordfor that page, backward chaining log records until an instantiated datablock is referenced. This approach may provide good performance formixed read-write workloads, including in applications in which reads arelargely cached.

In some embodiments, because accesses to the log-structured data storagefor the redo log records may consist of a series of sequentialinput/output operations (rather than random input/output operations),the changes being made may be tightly packed together. It should also benoted that, in contrast to existing systems in which each change to adata page results in two input/output operations to persistent datastorage (one for the redo log and one for the modified data pageitself), in some embodiments, the systems described herein may avoidthis “write amplification” by coalescing data pages at the storage nodesof the distributed storage system based on receipt of the redo logrecords.

As previously noted, in some embodiments, the storage tier of thedatabase system may be responsible for taking database snapshots.However, because the storage tier implements log-structured storage,taking a snapshot of a data page (e.g., a data block) may includerecording a timestamp associated with the redo log record that was mostrecently applied to the data page/block (or a timestamp associated withthe most recent operation to coalesce multiple redo log records tocreate a new version of the data page/block), and preventing garbagecollection of the previous version of the page/block and any subsequentlog entries up to the recorded point in time. For example, the log pagereclamation point may be determined so that log pages storing the logentries included in the snapshot are not reclaimed as part of efficientgarbage collection techniques, such as those described below with regardto FIG. 7. In such embodiments, taking a database snapshot may notrequire reading, copying, or writing the data block, as would berequired when employing an off-volume backup strategy. In someembodiments, the space requirements for snapshots may be minimal, sinceonly modified data would require additional space, althoughuser/subscribers may be able to choose how much additional space theywant to keep for on-volume snapshots in addition to the active data set.In different embodiments, snapshots may be discrete (e.g., each snapshotmay provide access to all of the data in a data page as of a specificpoint in time) or continuous (e.g., each snapshot may provide access toall versions of the data that existing in a data page between two pointsin time). In some embodiments, reverting to a prior snapshot may includerecording a log record to indicate that all redo log records and datapages since that snapshot are invalid and garbage collectable, anddiscarding all database cache entries after the snapshot point. In suchembodiments, no roll-forward may be required since the storage systemwill, on a block-by-block basis, apply redo log records to data blocksas requested and in the background across all nodes, just as it does innormal forward read/write processing. Crash recovery may thereby be madeparallel and distributed across nodes.

One embodiment of a service system architecture that may be configuredto implement a network-based services-based database service isillustrated in FIG. 2. In the illustrated embodiment, a number ofclients (shown as clients 250 a-250 n) may be configured to interactwith a network-based services platform 200 via a network 260.Network-based services platform 200 may be configured to interface withone or more instances of a database service 210, a distributed storageservice 220 and/or one or more other virtual computing services 230. Itis noted that where one or more instances of a given component mayexist, reference to that component herein may be made in either thesingular or the plural. However, usage of either form is not intended topreclude the other.

In various embodiments, the components illustrated in FIG. 2 may beimplemented directly within computer hardware, as instructions directlyor indirectly executable by computer hardware (e.g., a microprocessor orcomputer system), or using a combination of these techniques.

For example, the components of FIG. 2 may be implemented by a systemthat includes a number of computing nodes (or simply, nodes), each ofwhich may be similar to the computer system embodiment illustrated inFIG. 12 and described below. In various embodiments, the functionalityof a given service system component (e.g., a component of the databaseservice or a component of the storage service) may be implemented by aparticular node or may be distributed across several nodes. In someembodiments, a given node may implement the functionality of more thanone service system component (e.g., more than one database servicesystem component).

Generally speaking, clients 250 may encompass any type of clientconfigurable to submit network-based services requests to network-basedservices platform 200 via network 260, including requests for databaseservices (e.g., a request to generate a snapshot, etc.). For example, agiven client 250 may include a suitable version of a web browser, or mayinclude a plug-in module or other type of code module configured toexecute as an extension to or within an execution environment providedby a web browser. Alternatively, a client 250 (e.g., a database serviceclient) may encompass an application such as a database application (oruser interface thereof), a media application, an office application orany other application that may make use of persistent storage resourcesto store and/or access one or more databases. In some embodiments, suchan application may include sufficient protocol support (e.g., for asuitable version of Hypertext Transfer Protocol (HTTP)) for generatingand processing network-based services requests without necessarilyimplementing full browser support for all types of network-based data.That is, client 250 may be an application configured to interactdirectly with network-based services platform 200. In some embodiments,client 250 may be configured to generate network-based services requestsaccording to a Representational State Transfer (REST)-stylenetwork-based services architecture, a document- or message-basednetwork-based services architecture, or another suitable network-basedservices architecture.

In some embodiments, a client 250 (e.g., a database service client) maybe configured to provide access to network-based services-based storageof databases to other applications in a manner that is transparent tothose applications. For example, client 250 may be configured tointegrate with an operating system or file system to provide storage inaccordance with a suitable variant of the storage models describedherein. However, the operating system or file system may present adifferent storage interface to applications, such as a conventional filesystem hierarchy of files, directories and/or folders. In such anembodiment, applications may not need to be modified to make use of astorage system service model. Instead, the details of interfacing tonetwork-based services platform 200 may be coordinated by client 250 andthe operating system or file system on behalf of applications executingwithin the operating system environment.

Clients 250 may convey network-based services requests (e.g., a snapshotrequest, parameters of a snapshot request, read request, restore asnapshot, etc.) to and receive responses from network-based servicesplatform 200 via network 260. In various embodiments, network 260 mayencompass any suitable combination of networking hardware and protocolsnecessary to establish network-based-based communications betweenclients 250 and platform 200. For example, network 260 may generallyencompass the various telecommunications networks and service providersthat collectively implement the Internet. Network 260 may also includeprivate networks such as local area networks (LANs) or wide areanetworks (WANs) as well as public or private wireless networks. Forexample, both a given client 250 and network-based services platform 200may be respectively provisioned within enterprises having their owninternal networks. In such an embodiment, network 260 may include thehardware (e.g., modems, routers, switches, load balancers, proxyservers, etc.) and software (e.g., protocol stacks, accounting software,firewall/security software, etc.) necessary to establish a networkinglink between given client 250 and the Internet as well as between theInternet and network-based services platform 200. It is noted that insome embodiments, clients 250 may communicate with network-basedservices platform 200 using a private network rather than the publicInternet. For example, clients 250 may be provisioned within the sameenterprise as a database service system (e.g., a system that implementsdatabase service 210 and/or distributed storage service 220). In such acase, clients 250 may communicate with platform 200 entirely through aprivate network 260 (e.g., a LAN or WAN that may use Internet-basedcommunication protocols but which is not publicly accessible).

Generally speaking, network-based services platform 200 may beconfigured to implement one or more service endpoints configured toreceive and process network-based services requests, such as requests toaccess data pages (or records thereof). For example, network-basedservices platform 200 may include hardware and/or software configured toimplement a particular endpoint, such that an HTTP-based network-basedservices request directed to that endpoint is properly received andprocessed. In one embodiment, network-based services platform 200 may beimplemented as a server system configured to receive network-basedservices requests from clients 250 and to forward them to components ofa system that implements database service 210, distributed storageservice 220 and/or another virtual computing service 230 for processing.In other embodiments, network-based services platform 200 may beconfigured as a number of distinct systems (e.g., in a cluster topology)implementing load balancing and other request management featuresconfigured to dynamically manage large-scale network-based servicesrequest processing loads. In various embodiments, network-based servicesplatform 200 may be configured to support REST-style or document-based(e.g., SOAP-based) types of network-based services requests.

In addition to functioning as an addressable endpoint for clients'network-based services requests, in some embodiments, network-basedservices platform 200 may implement various client management features.For example, platform 200 may coordinate the metering and accounting ofclient usage of network-based services, including storage resources,such as by tracking the identities of requesting clients 250, the numberand/or frequency of client requests, the size of data tables (or recordsthereof) stored or retrieved on behalf of clients 250, overall storagebandwidth used by clients 250, class of storage requested by clients250, or any other measurable client usage parameter. Platform 200 mayalso implement financial accounting and billing systems, or may maintaina database of usage data that may be queried and processed by externalsystems for reporting and billing of client usage activity. In certainembodiments, platform 200 may be configured to collect, monitor and/oraggregate a variety of storage service system operational metrics, suchas metrics reflecting the rates and types of requests received fromclients 250, bandwidth utilized by such requests, system processinglatency for such requests, system component utilization (e.g., networkbandwidth and/or storage utilization within the storage service system),rates and types of errors resulting from requests, characteristics ofstored and requested data pages or records thereof (e.g., size, datatype, etc.), or any other suitable metrics. In some embodiments suchmetrics may be used by system administrators to tune and maintain systemcomponents, while in other embodiments such metrics (or relevantportions of such metrics) may be exposed to clients 250 to enable suchclients to monitor their usage of database service 210, distributedstorage service 220 and/or another virtual computing service 230 (or theunderlying systems that implement those services).

In some embodiments, network-based services platform 200 may alsoimplement user authentication and access control procedures. Forexample, for a given network-based services request to access aparticular database, platform 200 may be configured to ascertain whetherthe client 250 associated with the request is authorized to access theparticular database. Platform 200 may determine such authorization by,for example, evaluating an identity, password or other credentialagainst credentials associated with the particular database, orevaluating the requested access to the particular database against anaccess control list for the particular database. For example, if aclient 250 does not have sufficient credentials to access the particulardatabase, platform 200 may reject the corresponding network-basedservices request, for example by returning a response to the requestingclient 250 indicating an error condition. Various access controlpolicies may be stored as records or lists of access control informationby database service 210, distributed storage service 220 and/or othervirtual computing services 230.

It is noted that while network-based services platform 200 may representthe primary interface through which clients 250 may access the featuresof a database system that implements database service 210, it need notrepresent the sole interface to such features. For example, an alternateAPI that may be distinct from a network-based services interface may beused to allow clients internal to the enterprise providing the databasesystem to bypass network-based services platform 200. Note that in manyof the examples described herein, distributed storage service 220 may beinternal to a computing system or an enterprise system that providesdatabase services to clients 250, and may not be exposed to externalclients (e.g., users or client applications). In such embodiments, theinternal “client” (e.g., database service 210) may access distributedstorage service 220 over a local or private network, shown as the solidline between distributed storage service 220 and database service 210(e.g., through an API directly between the systems that implement theseservices). In such embodiments, the use of distributed storage service220 in storing databases on behalf of clients 250 may be transparent tothose clients. In other embodiments, distributed storage service 220 maybe exposed to clients 250 through network-based services platform 200 toprovide storage of databases or other information for applications otherthan those that rely on database service 210 for database management.This is illustrated in FIG. 2 by the dashed line between network-basedservices platform 200 and distributed storage service 220. In suchembodiments, clients of the distributed storage service 220 may accessdistributed storage service 220 via network 260 (e.g., over theInternet). In some embodiments, a virtual computing service 230 may beconfigured to receive storage services from distributed storage service220 (e.g., through an API directly between the virtual computing service230 and distributed storage service 220) to store objects used inperforming computing services 230 on behalf of a client 250. This isillustrated in FIG. 2 by the dashed line between virtual computingservice 230 and distributed storage service 220. In some cases, theaccounting and/or credentialing services of platform 200 may beunnecessary for internal clients such as administrative clients orbetween service components within the same enterprise.

Although not illustrated, in various embodiments distributed storageservice 220 may be configured to interface with backup data store,system, service, or device. Various data, such as data pages, logrecords, and/or any other data maintained by distributed storage serviceinternal clients, such as database service 210 or other virtualcomputing services 230, and/or external clients such as clients 250 athrough 250 n, may be sent to a backup data store.

Note that in various embodiments, different storage policies may beimplemented by database service 210 and/or distributed storage service220. Examples of such storage policies may include a durability policy(e.g., a policy indicating the number of instances of a database (ordata page thereof) that will be stored and the number of different nodeson which they will be stored) and/or a load balancing policy (which maydistribute databases, or data pages thereof, across different nodes,volumes and/or disks in an attempt to equalize request traffic). Inaddition, different storage policies may be applied to different typesof stored items by various one of the services. For example, in someembodiments, distributed storage service 220 may implement a higherdurability for redo log records than for data pages.

FIG. 3 is a block diagram illustrating various components of a databasesystem that includes a database engine and a separate distributeddatabase storage service, according to one embodiment. In this example,database system 300 includes a respective database engine head node 320for each of several databases and a distributed storage service 310(which may or may not be visible to the clients of the database system,shown as database clients 350 a-350 n). As illustrated in this example,one or more of database clients 350 a-350 n may access a database headnode 320 (e.g., head node 320 a, head node 320 b, or head node 320 c,each of which is a component of a respective database instance) vianetwork 360 (e.g., these components may be network-addressable andaccessible to the database clients 350 a-350 n). However, distributedstorage service 310, which may be employed by the database system tostore data pages of one or more databases (and redo log records and/orother metadata associated therewith) on behalf of database clients 350a-350 n, and to perform other functions of the database system asdescribed herein, may or may not be network-addressable and accessibleto the storage clients 350 a-350 n, in different embodiments. Forexample, in some embodiments, distributed storage service 310 mayperform various storage, access, change logging, recovery, log recordmanipulation, and/or space management operations in a manner that isinvisible to storage clients 350 a-350 n.

As previously noted, each database instance may include a singledatabase engine head node 320 that receives requests (e.g., a snapshotrequest, etc.) from various client programs (e.g., applications) and/orsubscribers (users), then parses them, optimizes them, and develops anexecution plan to carry out the associated database operation(s). In theexample illustrated in FIG. 3, a query parsing, optimization, andexecution component 305 of database engine head node 320 a may performthese functions for queries that are received from database client 350 aand that target the database instance of which database engine head node320 a is a component. In some embodiments, query parsing, optimization,and execution component 305 may return query responses to databaseclient 350 a, which may include write acknowledgements, requested datapages (or portions thereof), error messages, and or other responses, asappropriate. As illustrated in this example, database engine head node320 a may also include a client-side storage service driver 325, whichmay route read requests and/or redo log records to various storage nodeswithin distributed storage service 310, receive write acknowledgementsfrom distributed storage service 310, receive requested data pages fromdistributed storage service 310, and/or return data pages, errormessages, or other responses to query parsing, optimization, andexecution component 305 (which may, in turn, return them to databaseclient 350 a).

In this example, database engine head node 320 a includes a data pagecache 335, in which data pages that were recently accessed may betemporarily held. As illustrated in FIG. 3, database engine head node320 a may also include a transaction and consistency managementcomponent 330, which may be responsible for providing transactionalityand consistency in the database instance of which database engine headnode 320 a is a component. For example, this component may beresponsible for ensuring the Atomicity, Consistency, and Isolationproperties of the database instance and the transactions that aredirected that the database instance. As illustrated in FIG. 3, databaseengine head node 320 a may also include a transaction log 340 and anundo log 345, which may be employed by transaction and consistencymanagement component 330 to track the status of various transactions androll back any locally cached results of transactions that do not commit.

Note that each of the other database engine head nodes 320 illustratedin FIG. 3 (e.g., 320 b and 320 c) may include similar components and mayperform similar functions for queries received by one or more ofdatabase clients 350 a-350 n and directed to the respective databaseinstances of which it is a component.

In some embodiments, the distributed storage systems described hereinmay organize data in various logical volumes, segments, and pages forstorage on one or more storage nodes. For example, in some embodiments,each database is represented by a logical volume, and each logicalvolume is segmented over a collection of storage nodes. Each segment,which lives on a particular one of the storage nodes, contains a set ofcontiguous block addresses. In some embodiments, each data page isstored in a segment, such that each segment stores a collection of oneor more data pages and a change log (also referred to as a redo log)(e.g., a log of redo log records) for each data page that it stores. Asdescribed in detail herein, the storage nodes may be configured toreceive redo log records (which may also be referred to herein as ULRs)and to coalesce them to create new versions of the corresponding datapages and/or additional or replacement log records (e.g., lazily and/orin response to a request for a data page or a database crash). In someembodiments, data pages and/or change logs may be mirrored acrossmultiple storage nodes, according to a variable configuration (which maybe specified by the client on whose behalf the databases are beingmaintained in the database system). For example, in differentembodiments, one, two, or three copies of the data or change logs may bestored in each of one, two, or three different availability zones orregions, according to a default configuration, an application-specificdurability preference, or a client-specified durability preference.

As used herein, the following terms may be used to describe theorganization of data by a distributed storage system, according tovarious embodiments.

Volume: A volume is a logical concept representing a highly durable unitof storage that a user/client/application of the storage systemunderstands. More specifically, a volume is a distributed store thatappears to the user/client/application as a single consistent orderedlog of write operations to various user pages of a database. Each writeoperation may be encoded in a User Log Record (ULR), which represents alogical, ordered mutation to the contents of a single user page withinthe volume. As noted above, a ULR may also be referred to herein as aredo log record. Each ULR may include a unique identifier (e.g., aLogical Sequence Number (LSN)). Each ULR may be persisted to one or moresynchronous segments in the distributed store that form a ProtectionGroup (PG), to provide high durability and availability for the ULR. Avolume may provide an LSN-type read/write interface for a variable-sizecontiguous range of bytes.

In some embodiments, a volume may consist of multiple extents, each madedurable through a protection group. In such embodiments, a volume mayrepresent a unit of storage composed of a mutable contiguous sequence ofVolume Extents. Reads and writes that are directed to a volume may bemapped into corresponding reads and writes to the constituent volumeextents. In some embodiments, the size of a volume may be changed byadding or removing volume extents from the end of the volume.

Segment: A segment is a limited-durability unit of storage assigned to asingle storage node. More specifically, a segment provides limitedbest-effort durability (e.g., a persistent, but non-redundant singlepoint of failure that is a storage node) for a specific fixed-size byterange of data. This data may in some cases be a mirror ofuser-addressable data, or it may be other data, such as volume metadataor erasure coded bits, in various embodiments. A given segment may liveon exactly one storage node. Within a storage node, multiple segmentsmay live on each SSD, and each segment may be restricted to one SSD(e.g., a segment may not span across multiple SSDs). In someembodiments, a segment may not be required to occupy a contiguous regionon an SSD; rather there may be an allocation map in each SSD describingthe areas that are owned by each of the segments. As noted above, aprotection group may consist of multiple segments spread across multiplestorage nodes. In some embodiments, a segment may provide an LSN-typeread/write interface for a fixed-size contiguous range of bytes (wherethe size is defined at creation). In some embodiments, each segment maybe identified by a Segment UUID (e.g., a universally unique identifierof the segment).

Storage page: A storage page is a block of memory, generally of fixedsize. In some embodiments, each page is a block of memory (e.g., ofvirtual memory, disk, or other physical memory) of a size defined by theoperating system, and may also be referred to herein by the term “datablock”. More specifically, a storage page may be a set of contiguoussectors. It may serve as the unit of allocation in SSDs, as well as theunit in log pages for which there is a header and metadata. In someembodiments, and in the context of the database systems describedherein, the term “page” or “storage page” may refer to a similar blockof a size defined by the database configuration, which may typically amultiple of 2, such as 4096, 8192, 16384, or 32768 bytes.

Log page: A log page is a type of storage page that is used to store logrecords (e.g., redo log records or undo log records). In someembodiments, log pages may be identical in size to storage pages. Eachlog page may include a header containing metadata about that log page,e.g., metadata identifying the segment to which it belongs. Note that alog page is a unit of organization and may not necessarily be the unitof data included in write operations. For example, in some embodiments,during normal forward processing, write operations may write to the tailof the log one sector at a time.

Log Records: Log records (e.g., the individual elements of a log page)may be of several different classes. For example, User Log Records(ULRs), which are created and understood by users/clients/applicationsof the storage system, may be used to indicate changes to user data in avolume. Control Log Records (CLRs), which are generated by the storagesystem, may contain control information used to keep track of metadatasuch as the current unconditional volume durable LSN (VDL). Null LogRecords (NLRs) may in some embodiments be used as padding to fill inunused space in a log sector or log page. In some embodiments, there maybe various types of log records within each of these classes, and thetype of a log record may correspond to a function that needs to beinvoked to interpret the log record. For example, one type may representall the data of a user page in compressed format using a specificcompression format; a second type may represent new values for a byterange within a user page; a third type may represent an incrementoperation to a sequence of bytes interpreted as an integer; and a fourthtype may represent copying one byte range to another location within thepage. In some embodiments, log record types may be identified by GUIDs(rather than by integers or enums), which may simplify versioning anddevelopment, especially for ULRs.

Payload: The payload of a log record is the data or parameter valuesthat are specific to the log record or to log records of a particulartype. For example, in some embodiments, there may be a set of parametersor attributes that most (or all) log records include, and that thestorage system itself understands. These attributes may be part of acommon log record header/structure, which may be relatively smallcompared to the sector size. In addition, most log records may includeadditional parameters or data specific to that log record type, and thisadditional information may be considered the payload of that log record.In some embodiments, if the payload for a particular ULR is larger thanthe user page size, it may be replaced by an absolute ULR (an AULR)whose payload includes all the data for the user page. This may enablethe storage system to enforce an upper limit on the size of the payloadfor ULRs that is equal to the size of user pages.

Note that when storing log records in the segment log, the payload maybe stored along with the log header, in some embodiments. In otherembodiments, the payload may be stored in a separate location, andpointers to the location at which that payload is stored may be storedwith the log header. In still other embodiments, a portion of thepayload may be stored in the header, and the remainder of the payloadmay be stored in a separate location. If the entire payload is storedwith the log header, this may be referred to as in-band storage;otherwise the storage may be referred to as being out-of-band. In someembodiments, the payloads of most large AULRs may be stored out-of-bandin the cold zone of log (which is described below).

User pages: User pages are the byte ranges (of a fixed size) andalignments thereof for a particular volume that are visible tousers/clients of the storage system. User pages are a logical concept,and the bytes in particular user pages may or not be stored in anystorage page as-is. The size of the user pages for a particular volumemay be independent of the storage page size for that volume. In someembodiments, the user page size may be configurable per volume, anddifferent segments on a storage node may have different user page sizes.In some embodiments, user page sizes may be constrained to be a multipleof the sector size (e.g., 4 KB), and may have an upper limit (e.g., 64KB). The storage page size, on the other hand, may be fixed for anentire storage node and may not change unless there is a change to theunderlying hardware.

Data page: A data page is a type of storage page that is used to storeuser page data in compressed form. In some embodiments every piece ofdata stored in a data page is associated with a log record, and each logrecord may include a pointer to a sector within a data page (alsoreferred to as a data sector). In some embodiments, data pages may notinclude any embedded metadata other than that provided by each sector.There may be no relationship between the sectors in a data page.Instead, the organization into pages may exist only as an expression ofthe granularity of the allocation of data to a segment.

Storage node: A storage node is a single virtual machine that on whichstorage node server code is deployed. Each storage node may containmultiple locally attached SSDs, and may provide a network API for accessto one or more segments. In some embodiments, various nodes may be on anactive list or on a degraded list (e.g., if they are slow to respond orare otherwise impaired, but are not completely unusable). In someembodiments, the client-side driver may assist in (or be responsiblefor) classifying nodes as active or degraded, for determining if andwhen they should be replaced, and/or for determining when and how toredistribute data among various nodes, based on observed performance.

SSD: As referred to herein, the term “SSD” may refer to a local blockstorage volume as seen by the storage node, regardless of the type ofstorage employed by that storage volume, e.g., disk, a solid-statedrive, a battery-backed RAM, a non-volatile RAM device (e.g., one ormore NV-DIMMs) or another type of persistent storage device. An SSD isnot necessarily mapped directly to hardware. For example, a singlesolid-state storage device might be broken up into multiple localvolumes where each volume is split into and striped across multiplesegments, and/or a single drive may be broken up into multiple volumessimply for ease of management, in different embodiments. In someembodiments, each SSD may store an allocation map at a single fixedlocation. This map may indicate which storage pages that are owned byparticular segments, and which of these pages are log pages (as opposedto data pages). In some embodiments, storage pages may be pre-allocatedto each segment so that forward processing may not need to wait forallocation. Any changes to the allocation map may need to be madedurable before newly allocated storage pages are used by the segments.

One embodiment of a distributed storage system is illustrated by theblock diagram in FIG. 4. Although discussed in the context of theinteracting with database system 400, distributed storage system 410 maymore broadly illustrate the various components of a distributed storagesystem implementing log-structured storage. Thus storage system servernodes 430, 440, through 450 may each implement optimized log storage forasynchronous log updates as discussed in further detail below withregard to FIGS. 5A, 5B, 7 and 9-11. In some embodiments, storage nodes430-450 may perform garbage collection at the same or near the same time(i.e., synchronously), or independently (asynchronously) from oneanother. A centralized authority, such as volume manager (which may beanother node or instance implemented for the distribute storage system410, such as on one or more computing devices, such as computer system1200 described below with regard to FIG. 12) or other module, maydetermine a log reclamation point for the storage nodes 430-450according to the various methods and techniques discussed below withregard to FIG. 12, and broadcast the log reclamation point to thestorage nodes upon a change, increment or other modification of the logreclamation point, in various embodiments. For example, volume manager480 may direct, detect, and/or determine the archival of log recordsand/or other data maintained by distributed storage system 410 to backupdata storage, and determine a log reclamation point such that datablocks containing log records that are currently archived may be garbagecollected. Volume manager may then send a Garbage Collection LSN (GCL)to indicate the log reclamation point to storage nodes 430-450. Volumemanager may also implement various other techniques, such as thosedescribed below with regard to FIG. 7 in order to determine areclamation point for the log page reclamation point. In someembodiments, storage nodes 430-450 may also determine the logreclamation point, such as by requesting the log reclamation point fromvolume manager, or querying other storage nodes to reach a consensus onlog records that may be garbage collected.

In at least some embodiments, storage nodes 430-450 may store data fordifferent clients as part of a multi-tenant storage service. Forexample, the various segments discussed above and below with regard toFIG. 8, may correspond to different protection groups and volumes fordifferent clients. As noted above, some storage nodes may performgarbage collection independent from other storage nodes. Consider thescenario where a storage node maintains data for two different clients.One client's data may be actively accessed/modified, causing the logstructure for that data to grow quickly. Though, the other datamaintained for the other client may be accessed infrequently, garbagecollection may be performed to reclaim data blocks storing log recordsfor the other data in order to make more data blocks available for themore active log.

In some embodiments, a database system 400 may be a client ofdistributed storage system 410, which communicates with a databaseengine head node 420 over interconnect 460. As in the exampleillustrated in FIG. 3, database engine head node 420 may include aclient-side storage service driver 425. In this example, distributedstorage system 410 includes multiple storage system server nodes(including those shown as 430, 440, and 450), each of which includesstorage for data pages and redo logs for the segment(s) it stores, andhardware and/or software configured to perform various segmentmanagement functions. For example, each storage system server node mayinclude hardware and/or software configured to perform at least aportion of any or all of the following operations: replication (locally,e.g., within the storage node), coalescing of redo logs to generate datapages, snapshots (e.g., creating, restoration, deletion, etc.), logmanagement (e.g., manipulating log records), crash recovery, and/orspace management (e.g., for a segment). Each storage system server nodemay also have multiple attached storage devices (e.g., SSDs) on whichdata blocks may be stored on behalf of clients (e.g., users, clientapplications, and/or database service subscribers).

In the example illustrated in FIG. 4, storage system server node 430includes data page(s) 433, segment redo log(s) 435, segment managementfunctions 437, and attached SSDs 471-478. Again note that the label“SSD” may or may not refer to a solid-state drive, but may moregenerally refer to a local block-based storage volume, regardless of itsunderlying hardware. Similarly, storage system server node 440 includesdata page(s) 443, segment redo log(s) 445, segment management functions447, and attached SSDs 481-488; and storage system server node 450includes data page(s) 453, segment redo log(s) 455, segment managementfunctions 457, and attached SSDs 491-498.

As previously noted, in some embodiments, a sector is the unit ofalignment on an SSD and may be the maximum size on an SSD that can bewritten without the risk that the write will only be partiallycompleted. For example, the sector size for various solid-state drivesand spinning media may be 4 KB. In some embodiments of the distributedstorage systems described herein, each and every sector may include havea 64-bit (8 byte) CRC at the beginning of the sector, regardless of thehigher-level entity of which the sector is a part. In such embodiments,this CRC (which may be validated every time a sector is read from SSD)may be used in detecting corruptions. In some embodiments, each andevery sector may also include a “sector type” byte whose valueidentifies the sector as a log sector, a data sector, or anuninitialized sector. For example, in some embodiments, a sector typebyte value of 0 may indicate that the sector is uninitialized.

In some embodiments, each of the storage system server nodes in thedistributed storage system may implement a set of processes running onthe node server's operating system that manage communication with thedatabase engine head node, e.g., to receive redo logs, send back datapages, etc. In some embodiments, all data blocks written to thedistributed storage system may be backed up to long-term and/or archivalstorage (e.g., in a remote key-value durable backup storage system).

FIG. 5A is a block diagram illustrating the use of a separatedistributed storage system in a database system, according to oneembodiment. In this example, one or more client processes 510 may storedata to one or more databases maintained by a database system thatincludes a database engine 520 and a distributed storage system 530. Inthe example illustrated in FIG. 5A, database engine 520 includesdatabase tier components 560 and client-side driver 540 (which serves asthe interface between distributed storage system 530 and database tiercomponents 560). In some embodiments, database tier components 560 mayperform functions such as those performed by query parsing, optimizationand execution component 305 and transaction and consistency managementcomponent 330 of FIG. 3, and/or may store data pages, transaction logsand/or undo logs (such as those stored by data page cache 335,transaction log 340 and undo log 345 of FIG. 3).

In this example, one or more client processes 510 may send databasequery requests 515 (which may include read and/or write requeststargeting data stored on one or more of the storage nodes 535 a-535 n)to database tier components 560, and may receive database queryresponses 517 from database tier components 560 (e.g., responses thatinclude write acknowledgements and/or requested data). Each databasequery request 515 that includes a request to write to a data page may beparsed and optimized to generate one or more write record requests 541,which may be sent to client-side driver 540 for subsequent routing todistributed storage system 530. In this example, client-side driver 540may generate one or more redo log records 531 corresponding to eachwrite record request 541, and may send them to specific ones of thestorage nodes 535 of distributed storage system 530. Distributed storagesystem 530 may return a corresponding write acknowledgement 523 for eachredo log record 531 to database engine 520 (specifically to client-sidedriver 540). Client-side driver 540 may pass these writeacknowledgements to database tier components 560 (as write responses542), which may then send corresponding responses (e.g., writeacknowledgements) to one or more client processes 510 as one of databasequery responses 517.

In this example, each database query request 515 that includes a requestto read a data page may be parsed and optimized to generate one or moreread record requests 543, which may be sent to client-side driver 540for subsequent routing to distributed storage system 530. In thisexample, client-side driver 540 may send these requests to specific onesof the storage nodes 535 of distributed storage system 530, anddistributed storage system 530 may return the requested data pages 533to database engine 520 (specifically to client-side driver 540). In atleast some embodiments, the requested data pages may be serviced from adata page entry in a backstop data structure maintained at a storagenode 535 that maintains the data. Client-side driver 540 may send thereturned data pages to the database tier components 560 as return datarecords 544, and database tier components 560 may then send the datapages to one or more client processes 510 as database query responses517.

In some embodiments, various error and/or data loss messages 534 may besent from distributed storage system 530 to database engine 520(specifically to client-side driver 540). These messages may be passedfrom client-side driver 540 to database tier components 560 as errorand/or loss reporting messages 545, and then to one or more clientprocesses 510 along with (or instead of) a database query response 517.

In some embodiments, the APIs 531-534 of distributed storage system 530and the APIs 541-545 of client-side driver 540 may expose thefunctionality of the distributed storage system 530 to database engine520 as if database engine 520 were a client of distributed storagesystem 530. For example, database engine 520 (through client-side driver540) may write redo log records or request data pages through these APIsto perform (or facilitate the performance of) various operations of thedatabase system implemented by the combination of database engine 520and distributed storage system 530 (e.g., storage, access, changelogging, recovery, and/or space management operations). As illustratedin FIG. 5, distributed storage system 530 may store data blocks onstorage nodes 535 a-535 n, each of which may have multiple attachedSSDs. In some embodiments, distributed storage system 530 may providehigh durability for stored data block through the application of varioustypes of redundancy schemes.

FIG. 5B illustrates interactions among storage nodes in a protectiongroup implementing optimized storage and a database system, according tosome embodiments. As discussed above, redo log record(s) 531 may be sentto different storage nodes in distributed storage system 530. In atleast some embodiments, different redo log records may be sent tostorage nodes 535 that implement a protection group 590 for a portion ofthe database volume. Protection group 590, for example, is illustratedin FIG. 5B as composed of group members, storage node 535 a, storagenode 535 b, storage node 535 c, storage node 535 d, and storage node 535e. Different storage nodes may receive different log records, and maystill be durably maintained in satisfaction of a protection grouppolicy, such as a write quorum requirement. For example, if a writequorum requirement is 3/5 storage nodes, redo log record A may be sentand acknowledged at storage nodes 535 a, 535 b, and 535 c, while redolog record B may be sent and acknowledged at storage nodes, 535 c, 535d, and 535 e. Thus, storage nodes 535 a and 535 b maintain a differentlog record A than storage nodes 535 d and 535 e, and vice versa withrespect to log record B. As discussed above, with regard to FIG. 1. andbelow with regard to FIGS. 7 and 9, redo log records 531 sent to astorage node may be initially stored in a hot log portion, such as hotlog portions 536 a, 536 b, 536 c, 536 d, and 536 e respectively ofblock-based storage devices accessible to storage nodes 535 a, 535 b,535 c, 535 d, and 535 e.

In at least some embodiments, a synchronization or replication techniquemay be implemented to ensure that storage nodes of protection group 590may catch up to the same or similar version of data. FIG. 11, discussedin further detail below, illustrates various methods and techniques thatmay be implemented to replicate log records among storage nodes in aprotection group. The log records stored in the cold log portion may beevaluated to determine a completion point for log records maintained ata particular storage node. A completion point may be the point in thelog record sequence for which the log records are maintained at thestorage node have no holes or gaps for missing log records. As the coldlog portion may store log records in data blocks according to the logrecord sequence, the first gap or missing log record may be easilyidentified, such as at the end of a respective data block storing logrecords. Indexing structures for the cold log portion may be maintained,which may be searched to determine the completion point. Based, on thesequence completion points, storage nodes, such as storage node 535 amay identify another storage node that is further advanced in the logrecord sequence, such as 535 b, and request log records from 535 b tocomplete the log record sequence at 535 up to the sequence completionpoint at 535 b. This replication process may be performed amongst thestorage nodes of protection group 590, in the background, while stillprocessing and responding to the various requests illustrated in FIG.5A. In various embodiments, the log records that are received from otherstorage nodes may be directly stored to the cold log portion of theblock-based storage device, by-passing the hot log portion altogether(as illustrated at 570). However, in other embodiments, log records maybe sent to other storage nodes and first placed in the hot log portion.

Note that in various embodiments, the API calls and responses betweendatabase engine 520 and distributed storage system 530 (e.g., APIs531-534) and/or the API calls and responses between client-side driver540 and database tier components 560 (e.g., APIs 541-545) in FIG. 5 maybe performed over a secure proxy connection (e.g., one managed by agateway control plane), or may be performed over the public network or,alternatively, over a private channel such as a virtual private network(VPN) connection. These and other APIs to and/or between components ofthe database systems described herein may be implemented according todifferent technologies, including, but not limited to, Simple ObjectAccess Protocol (SOAP) technology and Representational state transfer(REST) technology. For example, these APIs may be, but are notnecessarily, implemented as SOAP APIs or RESTful APIs. SOAP is aprotocol for exchanging information in the context of network-basedservices. REST is an architectural style for distributed hypermediasystems. A RESTful API (which may also be referred to as a RESTfulnetwork-based service) is a network-based service API implemented usingHTTP and REST technology. The APIs described herein may in someembodiments be wrapped with client libraries in various languages,including, but not limited to, C, C++, Java, C# and Perl to supportintegration with database engine 520 and/or distributed storage system530.

As noted above, in some embodiments, the functional components of adatabase system may be partitioned between those that are performed bythe database engine and those that are performed in a separate,distributed, storage system. In one specific example, in response toreceiving a request from a client process (or a thread thereof) toinsert something into a database (e.g., to update a single data block byadding a record to that data block), one or more components of thedatabase engine head node may perform query parsing, optimization, andexecution, and may send each portion of the query to a transaction andconsistency management component. The transaction and consistencymanagement component may ensure that no other client process (or threadthereof) is trying to modify the same row at the same time. For example,the transaction and consistency management component may be responsiblefor ensuring that this change is performed atomically, consistently,durably, and in an isolated manner in the database. For example, thetransaction and consistency management component may work together withthe client-side storage service driver of the database engine head nodeto generate a redo log record to be sent to one of the nodes in thedistributed storage service and to send it to the distributed storageservice (along with other redo logs generated in response to otherclient requests) in an order and/or with timing that ensures the ACIDproperties are met for this transaction. Upon receiving the redo logrecord (which may be considered an “update record” by the storageservice), the corresponding storage node may update the data block, andmay update a redo log for the data block (e.g., a record of all changesdirected to the data block). In some embodiments, the database enginemay be responsible for generating an undo log record for this change,and may also be responsible for generating a redo log record for theundo log both of which may be used locally (in the database tier) forensuring transactionality. However, unlike in traditional databasesystems, the systems described herein may shift the responsibility forapplying changes to data blocks to the storage system (rather thanapplying them at the database tier and shipping the modified data blocksto the storage system).

A variety of different allocation models may be implemented for an SSD,in different embodiments. For example, in some embodiments, log entrypages and physical application pages may be allocated from a single heapof pages associated with an SSD device. This approach may have theadvantage of leaving the relative amount of storage consumed by logpages and data pages to remain unspecified and to adapt automatically tousage. It may also have the advantage of allowing pages to remainunprepared until they are used, and repurposed at will withoutpreparation. In other embodiments, an allocation model may partition thestorage device into separate spaces for log entries and data pages. Oncesuch allocation model is illustrated by the block diagram in FIG. 6 anddescribed below.

FIG. 6 is a block diagram illustrating how data and metadata may bestored on a given storage node (or persistent storage device) of adistributed storage system, according to one embodiment. In thisexample, SSD storage space 600 stores an SSD header and other fixedmetadata in the portion of the space labeled 610. It stores log pages inthe portion of the space labeled 620, and includes a space labeled 630that is initialized and reserved for additional log pages. One portionof SSD storage space 600 (shown as 640) is initialized, but unassigned,and another portion of the space (shown as 650) is uninitialized andunassigned. Finally, the portion of SSD storage space 600 labeled 660stores data pages. A base page storage portion 670 may be a fixed orassigned portion of SSD storage space 600 that maintains a respectiveentry for each user page.

In allocation approach illustrated in FIG. 6, valid log pages may bepacked into the beginning of the flat storage space. Holes that open updue to log pages being freed may be reused before additional log pageslots farther into the address space are used. For example, in the worstcase, the first n log page slots contain valid log data, where n is thelargest number of valid log pages that have ever simultaneously existed.In this example, valid data pages may be packed into the end of the flatstorage space. Holes that open up due to data pages being freed may bereused before additional data page slots lower in the address space areused. For example, in the worst case, the last m data pages containvalid data, where m is the largest number of valid data pages that haveever simultaneously existed.

In some embodiments, before a log page slot can become part of thepotential set of valid log page entries, it may need to be initializedto a value that cannot be confused for a valid future log entry page.This is implicitly true for recycled log page slots, since a retired logpage has enough metadata to never be confused for a new valid log page.However, when a storage device is first initialized, or when space isreclaimed that had potentially been used to store application datapages, the log page slots may need to be initialized before they areadded to the log page slot pool. In some embodiments,rebalancing/reclaiming log space may be performed as a background task.

In the example illustrated in FIG. 6, the current log page slot poolincludes the area between the first usable log page slot and the lastreserved log page slot. In some embodiments, this pool may safely growup to last usable log page slot without re-initialization of new logpage slots (e.g., by persisting an update to the pointer that identifiesthe last reserved log page slot). In this example, beyond the lastusable log page slot, the pool may grow up to the first used data pageslot by persisting initialized log page slots and persistently updatingthe pointer for the last usable log page slot. In this example, thepreviously uninitialized and unassigned portion of the SSD storage space600 shown as 650 may be pressed into service to store log pages. In someembodiments, the current log page slot pool may be shrunk down to theposition of the last used log page slot (which is identified by pointer)by persisting an update to the pointer for the last reserved log pageslot.

In the example illustrated in FIG. 6, the current data page slot poolincludes the area between the last usable log page slot and the end ofSSD storage space 600. In some embodiments, the data page pool may besafely grown to the position identified by the pointer to the lastreserved log page slot by persisting an update to the pointer to thelast usable log page slot. In this example, the previously initialized,but unassigned portion of the SSD storage space 600 shown as 640 may bepressed into service to store data pages. Beyond this, the pool may besafely grown to the position identified by the pointer to the last usedlog page slot by persisting updates to the pointers for the lastreserved log page slot and the last usable log page slot, effectivelyreassigning the portions of SSD storage space 600 shown as 630 and 640to store data pages, rather than log pages. In some embodiments, thedata page slot pool may be safely shrunk down to the position identifiedby the pointer to the first used data page slot by initializingadditional log page slots and persisting an update to the pointer to thelast usable log page slot.

In embodiments that employ the allocation approach illustrated in FIG.6, page sizes for the log page pool and the data page pool may beselected independently, while still facilitating good packing behavior.In such embodiments, there may be no possibility of a valid log pagelinking to a spoofed log page formed by application data, and it may bepossible to distinguish between a corrupted log and a valid log tailthat links to an as-yet-unwritten next page. In embodiments that employthe allocation approach illustrated in FIG. 6, at startup, all of thelog page slots up to the position identified by the pointer to the lastreserved log page slot may be rapidly and sequentially read, and theentire log index may be reconstructed (including inferredlinking/ordering). In such embodiments, there may be no need forexplicit linking between log pages, since everything can be inferredfrom LSN sequencing constraints.

In some embodiments, a segment may consist of different parts (orzones): one that contains a hot log, one that contains a cold log, onethat contains user page data, and a base page portion that includes anentry corresponding to an oldest or historical version of each user datapage. Zones are not necessarily contiguous regions of an SSD. Rather,they can be interspersed at the granularity of the storage page (or adata block). In addition, there may be a root page for each segment thatstores metadata about the segment and its properties. For example, theroot page for a segment may store the user page size for the segment,the number of user pages in the segment, the current beginning/head ofthe hot log zone (which may be recorded in the form of a flush number),the volume epoch, access control metadata, and/or base page storagemetadata or location information.

In some embodiments, the hot log zone may accept new writes from theclient as they are received by the storage node. Both Delta User LogRecords (DULRs), which specify a change to a user/data page in the formof a delta from the previous version of the page, and Absolute User LogRecords (AULRs), which specify the contents of a complete user/datapage, may be written completely into the log. Log records may be addedto this zone in approximately the order they are received (e.g., theyare not sorted by LSN) and they can span across log pages. The logrecords may be self-describing, e.g., they may contain an indication oftheir own size. In some embodiments, no garbage collection is performedin this zone. Instead, space may be reclaimed by truncating from thebeginning of the log after all required log records have been copiedinto the cold log. Log sectors in the hot zone may be annotated with themost recent known unconditional VDL each time a sector is written.Conditional VDL CLRs may be written into the hot zone as they arereceived, but only the most recently written VDL CLR may be meaningful.Thus, VSL CLRs may, in some embodiments, be marked as garbagecollectible in the hot log, and not moved to cold log storage.

In some embodiments, every time a new log page is written, it may beassigned a flush number. The flush number may be written as part ofevery sector within each log page. Flush numbers may be used todetermine which log page was written later when comparing two log pages.Flush numbers are monotonically increasing and scoped to an SSD (orstorage node). For example, a set of monotonically increasing flushnumbers is shared between all segments on an SSD (or all segments on astorage node).

In some embodiments, in the cold log zone, log records may be stored inincreasing order of their LSNs. In this zone, AULRs may not necessarilystore data in-line, depending on their size. For example, if they havelarge payloads, all or a portion of the payloads may be stored in thedata zone and they may point to where their data is stored in the datazone. In some embodiments, log pages in the cold log zone may be writtenone full page at a time, rather than sector-by-sector. Because log pagesin the cold zone are written a full page at a time, any log page in thecold zone for which the flush numbers in all sectors are not identicalmay be considered to be an incompletely written page and may be ignored.In some embodiments, in the cold log zone, DULRs may be able to spanacross log pages (up to a maximum of two log pages). However, AULRs maynot be able to span log sectors, e.g., so that a coalesce operation willbe able to replace a DULR with an AULR in a single atomic write.

Base page storage 670 may store the current or historical versions ofuser data pages in entries corresponding to user data pages. Forexample, a user page table, or other index, may include pointers, links,addresses, or some other form of mapping information or identifiers thatlead to entries corresponding to particular user data pages. In someembodiments, individual entries may vary, with some entries comprisingone or more data blocks or pages, while others comprise less than ablock or page. Alternatively, in some other embodiments each entrycorresponding to a user page may be a fixed, same size, such as 1 page.The data stored in entries may be compressed and/or encrypted accordingto user and/or system preference.

In some embodiments, the distributed storage systems described hereinmay maintain various data structures in memory. For example, for eachuser page present in a segment, a user page table may store a bitindicating whether or not this user page is “cleared” (i.e., whether itincludes all zeroes), the LSN of the latest log record from the cold logzone for the page, and an array/list of locations of all log recordsfrom the hot log zone for page. For each log record, the user page tablemay store the sector number, the offset of the log record within thatsector, the number of sectors to read within that log page, the sectornumber of a second log page (if the log record spans log pages), and thenumber of sectors to read within that log page. In some embodiments, theuser page table may also store the LSNs of every log record from thecold log zone and/or an array of sector numbers for the payload of thelatest AULR if it is in the cold log zone.

In various embodiments, efficient garbage collection may be implementedto reclaim data blocks from the cold log zone. FIG. 7 is a data flowdiagram illustrating optimized log-structured storage for asynchronousupdates, according to some embodiments. As noted above log recordsreceived at a storage node may be stored 710 in a hot log zone 720. Logrecords may be received out of order, appended to the hot log zone 720as they are received. For example, in FIG. 7 the ordering of log recordsproceeds from record 702 r, then 702 p, 702 q, 702 o, 702 n, 702 s, andfinally 702 m (contrary to a sequential ordering which might start with702 m to 702 s). Log records sent to a distributed storage system, suchas described above in FIG. 5A, may be sent asynchronously, leading tolog records received out of order at hot log 720.

As discussed above, log records may be moved from the hot log 720 to thecold log 740. The cold log zone is populated by copying log records fromthe hot log zone. In some embodiments, only log records whose LSN isless than or equal to the current unconditional volume durable LSN (VDL)or some other completion point, such as segment completion point (SCL)may be eligible to be copied to the cold log zone. When moving logrecords from the hot log zone to the cold log zone, some log records(such as many CLRs) may not need to be copied because they are no longernecessary. In addition, some additional coalescing of user pages may beperformed at this point, as illustrated at 770, which may reduce theamount of copying required. For example, multiple DULRs may be coalescedto generate a single AULR. In addition to coalescing, in someembodiments log records may be compressed according to variouscompression techniques that may be implemented by compression engine780. For example, various different loss-less compression techniques maybe performed to generate compressed versions of log records, which maybe tightly packed into a data block. In some embodiments, log recordsstored in data blocks may be grouped together in log pages (although inthe discussion with regard to FIG. 7 illustrates data blocks). In someembodiments, once a given hot zone block has been completely written andis no longer the newest hot zone data block, and all ULRs on the hotzone data block have been successfully copied to the cold log zone, thehot zone data block may be freed, and identified as garbage collectible.In some embodiments, garbage collection may be performed on hot log atthe end of the log, and thus, available storage space in the hot logportion may not be reclaimed until surrounding log records are alsodeemed collectible. Consider the example illustrated in FIG. 7. Logrecords 702 m, 702 n, 702 o, and 702 p, make up the next four logrecords in the log record sequence to be persisted after log record 702l. Log record 702 p may, for example, be less than the currentunconditional VDL or SCL, and thus, as illustrated by the dashed line,log records 702 m, 702 n, 702 o, and 702 p may be stored in a new datablock in cold log 740 (as well one or more log records linked to thesame user page may be coalesced 770 and along with all the log recordssent to the cold log portion 740 compressed 780).

Cold log zone 740 may, in various embodiments, maintain log records fora log-structured data store in data blocks, such as data blocksdescribed above. Data blocks 742, 744, and 746, for example, eachmaintain different log records, 702 a, 702 b, 702 c, 702 d, 702 e, 702f, 702 g, 702 h, 702 i, 702 j, 702 k, and 702 l respectively. The logrecords, of which many various descriptions presented above, may beAULRs, DULRs, or any other type of log record for the exampledistributed storage system described above, or any other log-structureddata store. These log records may be linked to or associated with a datapage. For example, a log record may describe anupdate/change/modification for some portion, or all, of the data page,such as change relative to a previous record or version of the data page(e.g., a DULR). In some embodiments, log records may be storedsequentially in data blocks. Thus, the latest LSN in the ordering of logrecords maintained in a data block may indicate that all log records inthe log page are prior to the latest LSN. Note that although data blocksare illustrated as containing the same number of log records, the numberof log records stored in a data block may vary, and thus theillustration in FIG. 7 is not intended to be limiting.

Base page storage 760, similar to base page storage 670 above, maymaintain entries or versions of user pages 762 a, 762 b, 762 c through762 n. For example, each entry in base page storage 760 may maintain areplica or copy of the respective user page. In some embodiments, eachentry may be compressed, encrypted, or otherwise modified. Other data,such as other log records linked to the data page, may also be storedwith the data page in the entry for the data page in backstop 760.

A storage node or other system maintaining cold log 740 may determinewhen to perform reclamation for log pages storing log records in coldlog 740, such as detecting a reclamation event or receiving anindication to reclaim data blocks. For example, the workload of astorage node, such as the amount of foreground processing beingperformed (e.g., servicing write requests or read requests) may fallbelow a workload threshold, or some other measure, which may indicatethat operational resources are available to perform data blockreclamation. In some embodiments, available storage space, such as thenumber of pages available to store new data, such as log records, userdata, or any other data, may be implemented. A storage node may alsoreceive an indication or instruction to perform reclamation of log pagesfrom another system or component of the distributed storage system, suchas volume manager discussed above with regard to FIG. 4.

The log records in cold log 740 may then be evaluated to identify datablocks to reclaim based, at least in part, on a cold log reclamationpoint 770. In some embodiments of the distributed storage systemsdescribed herein, an LSN index may be stored in memory. An LSN index maymap LSNs to data blocks within the cold log zone. Given that log recordsin cold log zone 740 are sorted, the index may include one entry perdata block. However, in some embodiments, every non-obsolete LSN may beidentified in the index and mapped to the corresponding sector numbers,offsets, and numbers of sectors for each log record.

In some embodiments of the distributed storage systems described herein,a log page table may be stored in memory, and the log page table may beused during garbage collection of the cold log zone. For example, thelog page table may identify which log records are obsolete (e.g., whichlog records can be garbage collected) and how much free space isavailable on each log page. As noted above, in some embodiments, groupsof data blocks storing log records may be grouped together into logpages, upon which the various efficient garbage collection techniquesmay be performed in order to reclaim one or more whole log pages at atime.

FIG. 7 illustrates an example of evaluating log records in cold log 740based on log reclamation point 770. Data blocks in the cold log 740 maybe examined to determine whether the one or more log records in the datablock are ready to be reclaimed. Data block 746 may include log records702 a, 702 b, 702 c, and 702 d. As noted above, each of these logrecords may, in some embodiments, include a sequence number, (e.g., LSNdescribed above), or some other ordering indicator. The log records inthe data block may then be compared to the log reclamation point 740. Iflog records are prior to cold log reclamation point 770 in the logrecord sequence, then the data block may be reclaimed. FIG. 7illustrates data blocks 742, 744, and 746, ordered according to thesequence of the log records they contain. In various embodiments, datablocks that may only contain log records less than, below or prior tocold log reclamation point 770 may be reclaimed. In the exampleillustrated in FIG. 7, data block 746 is identified for reclamation itfalls below the log reclamation point 770 for cold log 740.

As noted above, log reclamation point 770 may be determined in differentways. For example, in some embodiments log reclamation point may be agarbage collection LSN (GCL) or some other indicator that is receivedfrom another storage system component, such as volume manager in FIG. 4.The GCL may indicate that log records prior to the GCL (i.e. log recordswith lower LSNs) may have already been backed up to a data archive. Forexample, as illustrated in FIG. 2, other virtual computing services 230may be a network-based data archive to which distributed storage service220 may backup data to. Other data archive systems may also beimplemented. A GCL may also be generated in response to user/clientstorage action, such as the creation of a snapshot of the database. Asnapshot may be an indication that versions of data indicated by logrecords prior to the data pages may not need to be preserved at thestorage node. Log reclamation point 770 may also be determined based, atleast in part, on service level agreement, protocol, or some other dataretention policy for preserving data. Storage nodes storing a segmentmay enforce the service level agreement, protocol, or schema individual,or concert with the distributed storage system, such as via a volumemanager.

In various embodiments, the evaluation of the log records in the coldlog 740 may be performed by comparing the most recent log record (e.g.,702 d, 702 h, 702 l) in a particular data block with log reclamationpoint 770, as the log records in a data block may be sorted according totheir sequence. Alternatively, in some embodiments, mapping informationsuch as an index (such as the index described in further detail below)or other data structure may include information such as the range of logrecords located in a particular data block, thus cold log 740 may beevaluated by evaluating the index structure for the cold log 740. Datablocks that are identified as maintaining log records in the log recordsequence prior to the log reclamation point may be identified forreclamation.

For data blocks that have been identified for reclamation, the logrecords from the data block may be obtained and used to generate a newversion of the respective user pages to which they are linked. Asillustrated in FIG. 7, the newly generated versions of data pages may bestored 750 in entries for the respective data pages in base page storage760. In some embodiments, the log records may be applied to a previousversion of the page to which they are linked, and then a new version ofthe page may be generated. Log records may also indicate a new value forthe data page or the entire data page itself (e.g., AULR). Please note,that the records, log pages, data pages, etc. illustrated in FIG. 7 areprovided for illustrative purposes only, and are not intended to belimiting. For example, log pages may contain different numbers of logrecords. Moreover, log pages may not be laid out in sequential order inphysical storage.

Data blocks identified for reclamation, such as data block 746, may bereclaimed. The log records in the data block may be read. Then, thechanges indicated by the log record may be applied to a previous versionof a user data page to which they are linked. For example, if the logrecord indicates that a particular record value is to state “blue”instead of the prior value of “red,” then the version of the user datapage with the prior value read may also be obtained/read, and the newvalue “blue” written in to replace “red.” This process and/or similarprocesses of applying log records in identified data blocks mayultimately generate new versions of user pages 750, which may then bestored in their corresponding entries in base page storage 760. Forexample, multiple log records in data blocks being reclaimed may belinked to the same user page. For example, each log record may beupdating the same record value (e.g., daily sales). Each of the logrecords in data blocks being reclaimed may be applied to the user pageto which they are linked. In some embodiments, the log records frommultiple data blocks may be applied in a batch or in one or more groupsto generate one or more successive versions of the corresponding userpage.

Once all of the log records from data blocks being reclaimed have beenapplied to generate new versions, the data blocks themselves may bereclaimed for storing new data. For example, in some embodiments, thelog page table or other index, listing, or metadata describing availabledata blocks (or pages) may be updated to include the newly reclaimeddata blocks. In some embodiments, a reformat process may be applied tomake the data blocks ready for new data, while in other embodiments, thedata blocks may already be in the correct format to store new data.

In the storage systems described herein, an extent may be a logicalconcept representing a highly durable unit of storage that can becombined with other extents (either concatenated or striped) torepresent a volume. Each extent may be made durable by membership in asingle protection group. An extent may provide an LSN-type read/writeinterface for a contiguous byte sub-range having a fixed size that isdefined at creation. Read/write operations to an extent may be mappedinto one or more appropriate segment read/write operations by thecontaining protection group. As used herein, the term “volume extent”may refer to an extent that is used to represent a specific sub-range ofbytes within a volume.

As noted above, a volume may consist of multiple extents, eachrepresented by a protection group consisting of one or more segments. Insome embodiments, log records directed to different extents may haveinterleaved LSNs. For changes to the volume to be durable up to aparticular LSN it may be necessary for all log records up to that LSN tobe durable, regardless of the extent to which they belong. In someembodiments, the client may keep track of outstanding log records thathave not yet been made durable, and once all ULRs up to a specific LSNare made durable, it may send a Volume Durable LSN (VDL) message to oneof the protection groups in the volume. The VDL may be written to allsynchronous mirror segments for the protection group. This is sometimesreferred to as an “Unconditional VDL” and it may be periodicallypersisted to various segments (or more specifically, to variousprotection groups) along with write activity happening on the segments.In some embodiments, the Unconditional VDL may be stored in log sectorheaders.

In various embodiments, the operations that may be performed on asegment may include writing a DULR or AULR received from a client (whichmay involve writing the DULR or AULR to the tail of the hot log zone andthen updating the user page table), reading a cold user page (which mayinvolve locating the data sectors of the user page and returning themwithout needing to apply any additional DULRs), reading a hot user page(which may involve locating the data sectors of the most recent AULR forthe user page and apply any subsequent DULRs to the user page beforereturning it), replacing DULRs with AULRs (which may involve coalescingDULRs for a user page to create an AULR that replaces the last DULR thatwas applied), manipulating the log records, etc. As described hereincoalescing is the process of applying DULRs to an earlier version of auser page to create a later version of the user page. Coalescing a userpage may help reduce read latency because (until another DULR iswritten) all DULRs written prior to coalescing may not need to be readand applied on demand. It may also help reclaim storage space by makingold AULRs and DULRs obsolete (provided there is no snapshot requiringthe log records to be present). In some embodiments, a coalescingoperation may include locating a most recent AULR and applying anysubsequent DULRs in sequence without skipping any of the DULRs. As notedabove, in some embodiments, coalescing may not be performed within thehot log zone. Instead, it may be performed within the cold log zone. Insome embodiments, coalescing may also be performed as log records arecopied from the hot log zone to the cold log zone.

In some embodiments, the decision to coalesce a user page may betriggered by the size of the pending DULR chain for the page (e.g., ifthe length of the DULR chain exceeds a pre-defined threshold for acoalescing operation, according to a system-wide, application-specificor client-specified policy)), or by the user page being read by aclient.

FIG. 8 is a block diagram illustrating an example configuration of adatabase volume 810, according to one embodiment. In this example, datacorresponding to each of various address ranges 815 (shown as addressranges 815 a-815 e) is stored as different segments 845 (shown assegments 845 a-845 n). More specifically, data corresponding to each ofvarious address ranges 815 may be organized into different extents(shown as extents 825 a-825 b, and extents 835 a-835 h), and variousones of these extents may be included in different protection groups 830(shown as 830 a-830 f), with or without striping (such as that shown asstripe set 820 a and stripe set 820 b). In this example, protectiongroup 1 illustrates the use of erasure coding. In this example,protection groups 2 and 3 and protection groups 6 and 7 representmirrored data sets of each other, while protection group 4 represents asingle-instance (non-redundant) data set. In this example, protectiongroup 8 represents a multi-tier protection group that combines otherprotection groups (e.g., this may represent a multi-region protectiongroup). In this example, stripe set 1 (820 a) and stripe set 2 (820 b)illustrates how extents (e.g., extents 825 a and 825 b) may be stripedinto a volume, in some embodiments.

More specifically, in this example, protection group 1 (830 a) includesextents a-c (835 a-835 c), which include data from ranges 1-3 (815 a-815c), respectively, and these extents are mapped to segments 1-4 (845a-845 d). Protection group 2 (830 b) includes extent d (835 d), whichincludes data striped from range 4 (815 d), and this extent is mapped tosegments 5-7 (845 e-845 g). Similarly, protection group 3 (830 c)includes extent e (835 e), which includes data striped from range 4 (815d), and is mapped to segments 8-9 (845 h-845 i); and protection group 4(830 d) includes extent f (835 f), which includes data striped fromrange 4 (815 d), and is mapped to segment 10 (845 j). In this example,protection group 6 (830 e) includes extent g (835 g), which includesdata striped from range 5 (815 e), and is mapped to segments 11-12 (845k-845 l); and protection group 7 (830 f) includes extent h (835 h),which also includes data striped from range 5 (815 e), and is mapped tosegments 13-14 (845 m-845 n).

The various embodiments of a distributed storage system described withregard to FIGS. 2-8 above, may implement one or more differenttechniques for implementing optimized log storage for asynchronous logupdates. Optimized log storage is not limited to such systems, however.Various other kinds of log-structured storage may implement optimizedlog storage for asynchronous log updates. For example, log-structureddata stores may not be organized into protection groups or quorum sets,but instead may propagate changes from one storage node implementing theoptimized log storage to another in order to provide updates to multiplenodes in a distributed system. Alternatively, a single system or deviceimplementing optimized log storage may provide a private backing storefor a client system, device or application that issues asynchronousupdates to a log. FIG. 9 is a high-level flowchart illustrating a methodto implement optimized log storage for asynchronous log updates,according to some embodiments. Different combinations of systems and/ordevices may implement the various techniques discussed below.

As indicated at 910, log records indicating updates to data stored for astorage client and indicating respective positions in a log recordsequence may be received, in various embodiments. Log records maygenerally describe, represent, indicate, or contain updates, changes, ormodifications to data, or the data itself, as well as updates, changes,or modifications to metadata, or the metadata itself. Different storageclients may generate specific types of log records, such as the variousredo log records, undo log records, AULRs, DULRs, CLRs, etc. . . .described above with regard to FIGS. 2-8. Log records may also indicatea respective position in a log record sequence. For example, anindicator, such as a log sequence number (LSN) may be used to indicate aposition in a log record sequence.

As indicated at 920, in some embodiments, the received log records maybe stored in a hot log portion of a non-volatile storage device. Anon-volatile storage device may provide data storage that maintains datain the event of a system failure. For example, in some embodiments, anon-volatile storage device may non-volatile RAM (NV-RAM), battery orsuper-capacitor backed RAM, various different post NAND flash and/orsystem memory technologies, such as memristor based resistive randomaccess memory (ReRAM), three-dimensional NAND technologies,Ferroelectric RAM, magnetoresistive RAM (MRAM), or any of various typesof phase change memory (PCM). However, in some embodiments, thenon-volatile storage device may be a block-based storage device, such asthe same block-based storage device that may include a cold log portion.Thus, in the discussion below, the hot log portion of the non-volatilestorage device may be referred to as the hot log portion of theblock-based storage device. Therefore, the following discussion with thehot log portion being presented as part of the same block-based storagedevice is not intended to be limiting to other embodiments where thenon-volatile storage device is different from the block-based storagedevice (e.g., is implemented by one of the various technologiesdiscussed above).

The log records may be stored according to an order in which they arereceived. For instance, if log records with LSNs 103, 105, and 108, arereceived, then these log records may be stored in the hot log portion ofthe block-based storage device in this order. However, the log recordsthemselves may not necessarily be received according to the log recordsequence, in some embodiments. For example, a log record with an LSN 110(which indicates the log record's position in the log sequence order)may be received before a log record with LSN 100, and stored before itin the hot log portion. Log records may arrive out-of-order for variousreasons. Log records may be sent, from a storage client, out-of-order,for example. Log records may also become delayed, corrupted and re-sent,or affected by some other network or communication error between thestorage client and log-storage optimized for asynchronous log updates.Although various embodiments may process log records synchronously, inat least some embodiments asynchronous processing and storage of logrecords may lead to log records being received out-of-order.

The hot log records may, in some embodiments, be stored in the hot logportion by packing together the stored log records, such that the logrecords themselves may cross write or storage units of the storagedevice, (e.g., across data block or sector boundaries). In at least someembodiments, log records may be stored in separate or distinguishableunits of the storage device, such that each log record may be stored ina distinguishable and/or separately accessible location.

Upon storing log records in the hot log portion, an index structure forthe hot log portion may be updated. The hot log index structure may beproportionate to the number of log records stored in the hot logportion. The hot log index may include various metadata about the logrecords, such as their position in the log record sequence (e.g., LSN),relationship or dependencies upon other log records, type, or size, aswell as various other status indicators about the log record (e.g.,whether or not the log record is garbage collectible).

In some embodiments, in response to storing each log record, anacknowledgment of the log record may be sent, as indicated at 930. Asnoted above, asynchronous processing of log records may allow alog-structured storage system to acknowledge log records out-of-ordercompared to the log record sequence. A storage client may be able toreceive these acknowledgments and determine a completion point in thesequence of log records sent for storage.

As indicated at 940, log records in the hot log portion to move to acold log portion of the block-based storage device may be identified, invarious embodiments. The identified log records may complete a nextportion of a log record sequence that is not currently stored in thecold log portion of the block-based storage device. Consider thescenario, where the cold log portion stores log records with LSNs 1-100,and where the hot log portion stores log records with LSNs 101, 102,103, 105, 109, and 107. Those log records that complete a next portionof the log record sequence in the cold log portion, log records afterLSN 100, may be identified as completing a next portion of the logrecord sequence. Thus, log records with LSNs 101, 102, and 103 may beidentified to move from the hot log portion to the cold log portion.Please note, that in some embodiments, LSNs, may be sparsely assigned tolog records, and thus the previous LSN in the log record sequence maynot necessarily be the previous contiguous LSN. For example, given theexample log records above, LSN 107 may be the log record immediatelyprior to LSN 109 in the log record sequence (instead of LSN 108.

In order to determine or identify log records that are to be move, thehot log index structure may, in various embodiments, be evaluated toidentify log records currently stored in the hot log portion, ascertainthe completeness of the log records according to the log recordsequence, and exclude log records that may, or may not be eligible forstorage in the cold log portion of the block-based storage device. Forexample, some log records may be marked or identified as garbagecollectible, and may not be persisted in the cold log storage.

As indicated at 950, log records may be stored together in a data blockof the cold log portion according to the log record sequence, in variousembodiments. These log records may be exact, or nearly exact copies oflog records identified in the hot log portion, or these log records maybe a modified version of the log records. FIG. 10, discussed in furtherdetail below, provides various examples of modifications made to logrecords prior to storage in the cold log portion. A combination ofmodified and unmodified log records may also be stored in the cold logportion. The updates included in the identified log records at 940 maybe included the log records stored in the cold log portion, even thoughthey may not be represented by the log records stored in the cold log inthe same way. For example, if multiple log records that update a userdata page are coalesced together to one log record, (e.g., such as bycombining DULRs into an AULR), then the updates of the multiple logrecords may be considered to be included in the one log record (thoughnot necessarily distinguishable from other updates also included in theone log record).

A cold log portion index may be updated to reflect the storage of logrecords in the cold log portion of the storage device, in someembodiments. As log records may be stored in order of the log recordsequence within the data blocks of the cold log storage, the cold logportion index may be lightweight, and quickly traversed using suchsearch algorithms as binary search.

In some embodiments, log records may be stored to the cold log portionin such a way as to prevent (or identify) torn writes or incompletewrites. For example, a two phase commit process may be used where it mayfirst be determined that the cold log portion is ready to accept the logrecords, and a determination that the log records have actually beenstored in the cold log portion, before index structures for the hot andcold log are updated to reflect the change.

In various embodiments, a queue or some other data structure maymaintain a listing of or plan of identified log records to store in thecold log portion. Moving log records from the hot log portion to thecold log portion may, in some embodiments, be performed as a backgroundprocess and/or when resources are available to identify and/or move logrecords. The data structure maintaining identified log records may beevaluated to determine the next one or more log records to move (ormodify for movement) to cold log storage. In some embodiments, logrecords may not be stored in the cold log storage until exceeding ablock-write threshold such that free space in a minimum write size for astorage device (e.g., block or sector) is not wasted (i.e. fragmented).

Although identifying and/or storing log records in the cold log portionmay be implemented as a background process, in some embodiments,foreground processing, such as receiving, storing, and acknowledging logrecords at the hot log portion may be throttled, delayed, or halted. Forexample, the hot log portion of the block-based storage device mayexceed a hot log maximum size threshold. In response, new log recordssent to a storage device may not be stored in the hot log until theenough log records are moved from the hot log portion to the cold logportion and space in the hot log garbage collected sufficient to lowerthe size of the hot log below the hot log maximum size threshold.

Garbage collection at the hot log may be performed from the tail of thelog, in various embodiments. In other embodiments, various moving andcompaction techniques may be performed. The hot log portion, or the hotlog portion index, may be evaluated to identify log records that may nolonger need to be persisted, and thus be identified as garbagecollectible. For example, the UVCL record discussed above with regard toFIGS. 2-8, checkpoint indicators, two-phase commit acknowledgments, logrecords that are no longer to be retained due a retention policy, or anyother type of log record that is obsolete may be marked or identifiedfor garbage collection.

In some embodiments, the techniques described above with regard to FIG.9, may be performed at log-structured storage systems that aremulti-tenant (e.g., such as the distributed storage service describedabove with regard to FIGS. 2-8), storing data for multiple differentstorage clients. A single hot log portion may be maintained thatreceives log records from each the multiple storage clients, storingthem in the same hot log portion. Upon identifying, (possiblymodifying), and log records to be moved to the cold log, log records maybe stored in dedicated cold logs for each storage client, that aredistinct from (e.g., on another storage device, or separate partition ofa storage device) the other cold logs. In this way, a single process mayreceive, store, and/or acknowledge log records for multiple storageclients.

As discussed above, some log records identified for movement to the coldlog portion, may be modified prior to storage in the cold log portion.FIG. 10 is a high-level flowchart illustrating methods and techniques tomodify log records prior to cold log storage, according to someembodiments. As indicated at 1010, log records may be read from a hotlog portion, which have been identified for movement to a cold logportion of a block-based storage device, in some embodiments. At leastone of the read log records may be modified to generate a modified logrecord, as indicated at 1020. In some embodiments, a modified log recordmay include updates from one or more log records, and combined to createa single log record. In some embodiments, a single log record may bemodified to generate multiple modified log records. Log records may alsobe modified to create altered or changed versions of the same logrecord.

In at least some embodiments, multiple log records may be coalesced toform one or more other log records including the changes indicated inthe multiple log records. For example, in some embodiments, the numberof log records linked in a dependency chain (e.g., linked to the samedata page) in the hot log portion of the storage device (and identifiedfor movement to the cold log portion) may exceed a coalesce threshold.In response to exceeding the coalesce threshold, as described above withregard to FIGS. 2-8, log records may be coalesced to generate a new logrecord that indicates the changes (or the result of the changes in a logrecord) in the log records linked in the chain of dependencies. Thus,for example, if 5 DULRs are linked to the same user data page, and thecoalesce threshold is 3, the 5 DULRs may be coalesced to form an AULR,which includes the effects of the 5 DULRs in the log record. The AULRmay be included with log records written to the cold log portion,instead of the 5 DULRs (which may be marked as garbage collectible). Inat least some embodiments, the modified log record may be assigned thelatest LSN or indicator of position in the log record sequence of thelog records used to generate the modified version.

In at least some embodiments, modified log records may be compressed logrecords. For example, one or more compression techniques may be appliedto log records identified for movement to the cold log portion of theblock-based storage device to generate compressed versions of the logrecords. Various different loss-less data compression techniques may beimplemented including, but not limited, to Lempel-Ziv, run-length,dictionary-based, or bzip. Similarly, or in addition to compression, oneor more different encryption techniques may be implemented to generateencrypted versions of log records prior to storage in the cold logportion.

As indicated at 1030, the modified log record(s) may be included in thelog records stored to the cold log portion of the block-based storagedevice, in various embodiments. For instance, if 3 out of 10 identifiedlog records are coalesced to generate a single log record, then it maybe that only the 8 log records (1 modified+7 remaining) may be stored inthe cold log. In some embodiments, the characteristics of modified logrecords may be included in determinations of how many log records tostore in the cold log and/or when to store them. For example, if aftercompressing identified log records, a minimum block write size thresholdis not met (leaving a certain amount of wasted space), storing thecompressed log records may be delayed until other log records areidentified that may meet the minimum block write size thresholdcriteria.

As indicated at 1040, in some embodiments, log records from the hot logportion of the block-based storage device that have been stored in thecold log portion of the block-based storage device may be identified asgarbage collectible. For example, the log records illustrated as storedin the cold log portion in FIG. 7, log records 702 m, 702 n, 702 o, and702 p, from the hot log may be marked as garbage collectible. Garbagecollection in the hot log may be performed in a variety of differentways. In some embodiments, an in-memory data structure that provides anindex of specific log records may be used to determine where log recordsmarked as garbage collectible are located. As a majority of log recordseventually are moved to the cold log portion of the block-based storagedevice, the in-memory data structure for the hot log portion may be moredetailed, as the relative number of log records in the hot log portion(as compared to the total number of stored log records) may be verysmall. The in-memory data structure of log records in the hot logportion of the storage device may make garbage collection moreefficient. For example, moving and compacting techniques may be able toeasily determine which log records can be combined into different datablocks (or data pages), as well as which data blocks (or data pages) canbe quickly reclaimed. Once garbage collection for log records in the hotlog portion is complete, the reclaimed portions of the block-basedstorage device may be ready to store new log records for the hot log.

In various embodiments, optimized log structured storage may be used toimplement various other log-structured storage operations. For example,the cold log portion may be used to implement efficient garbagecollection for log records, as described above with regard to FIG. 7.Similarly, replication of log records may also utilize optimized logstorage for asynchronous writes, such as illustrated in FIG. 5B. FIG. 11is a high-level flowchart of efficient log-record replication acrossstorage nodes in a protection group using optimized log storage,according to some embodiments. The methods and techniques discussedbelow may be performed in parallel with the techniques discussed abovewith regard to FIGS. 8 and 9, as well as other foreground processes,such as illustrated in FIG. 5A.

As indicated at 1110, log records stored according to log recordsequence in a cold log portion of a block-based storage device may beevaluated to identify log records indicating updates to data stored fora storage client that are not currently persisted in the cold logportion. In various embodiments, a cold log index may be maintained thatindicates a respective entry for each data block in cold log storageindicating a position in the log record sequence for a first log recordin the data block. The indicated position for the first log record in adata block may, for instance, indicate whether positions of log recordsin the log record sequence below or above the log record may be stored,as a result of the log records stored in the cold log portion accordingto the log record sequence. Consider the scenario where log recordsstored in a data block are stored according to LSN value. The cold logindex entry for some data blocks may indicate an LSN value for each datablock (e.g., block 1, has LSN 10001, block 2 has LSN 10010, block 3 hasLSN 10030, etc. . . . ). As the log records are stored in the datablocks in the cold log portion according to LSN order, the cold logindex may be evaluated to identify which data block would, for instance,contain LSN 10007 (which would be data block 1 in this scenario). Inthis way, a light weight index for searching the cold log may bemaintained, which may not have to provide a direct mapping for every logrecord position in the log record sequence.

In various embodiments, the cold log index may be scanned to identifythe last log record in the log record sequence that is complete. Acompletion point may be the point in the log record sequence for whichthe log records are maintained at the storage node have no holes or gapsfor missing log records. As the cold log portion may store log recordsin data blocks according to the log record sequence, the first gap ormissing log record may be easily identified, such as at the end of arespective data block storing log records. A storage node, such asillustrated in FIG. 5A, may receive completion points from other storagenodes storing log records for the storage client using variouspeer-to-peer or gossip protocols. Based, on the received sequencecompletion points for other storage nodes, another storage node may beidentified that is further advanced in the log record sequence (e.g., byhaving a higher completion point). The range of log records between thetwo completion points, that of the current node and that of the advancednode may identify the log records in the log record sequence that arenot persisted on the current storage node.

As indicated at 1120, the identified log records may be requested fromother storage nodes storing log records for the storage client, invarious embodiments. For example, the current storage node may requestfrom the storage node that is further advanced, some or all of therequested log records. In some embodiments, different requests may besent to different storage nodes for the same or different log records.The identified log records may be received from the various storagenodes in the protection group, as indicated at 1130. In someembodiments, log records received at a storage node may be processedaccording to the technique illustrated in FIG. 9, storing first in thehot log and subsequently moving to the cold log. However, in at leastsome embodiments, as indicated at 1140, the received log records may bestored directly into data blocks in the cold log portion of theblock-based storage device according to the log record sequence. In thisway, the cold log portion may act as a second append point for logrecords in the replication, saving operational resources at the hot logfor performing foreground operations and/or client requests. Once storedin the cold log portion, the cold log record index may be updated toreflect the received log records.

Please note that the method illustrated in FIG. 11, is not to beconstrued as limiting to the various other ways log records may beprocessed. As noted above, log records received from other storage nodesmay be first stored in the hot log portion of the block-based storagedevice. In some embodiments, some log records received from the storagenode may be stored in the hot log portion, while other log records (suchas those fill a data block in the cold log portion) may be stored in thecold log portion of the block-based storage device.

The methods described herein may in various embodiments be implementedby any combination of hardware and software. For example, in oneembodiment, the methods may be implemented by a computer system (e.g., acomputer system as in FIG. 12) that includes one or more processorsexecuting program instructions stored on a computer-readable storagemedium coupled to the processors. The program instructions may beconfigured to implement the functionality described herein (e.g., thefunctionality of various servers and other components that implement thedatabase services/systems and/or storage services/systems describedherein). The various methods as illustrated in the figures and describedherein represent example embodiments of methods. The order of any methodmay be changed, and various elements may be added, reordered, combined,omitted, modified, etc.

FIG. 12 is a block diagram illustrating a computer system configured toimplement at least a portion of the database systems described herein,according to various embodiments. For example, computer system 1200 maybe configured to implement a database engine head node of a databasetier, or one of a plurality of storage nodes of a separate distributedstorage system that stores databases and associated metadata on behalfof clients of the database tier, in different embodiments. Computersystem 1200 may be any of various types of devices, including, but notlimited to, a personal computer system, desktop computer, laptop ornotebook computer, mainframe computer system, handheld computer,workstation, network computer, a consumer device, application server,storage device, telephone, mobile telephone, or in general any type ofcomputing device.

Computer system 1200 includes one or more processors 1210 (any of whichmay include multiple cores, which may be single or multi-threaded)coupled to a system memory 1220 via an input/output (I/O) interface1230. Computer system 1200 further includes a network interface 1240coupled to I/O interface 1230. In various embodiments, computer system1200 may be a uniprocessor system including one processor 1210, or amultiprocessor system including several processors 1210 (e.g., two,four, eight, or another suitable number). Processors 1210 may be anysuitable processors capable of executing instructions. For example, invarious embodiments, processors 1210 may be general-purpose or embeddedprocessors implementing any of a variety of instruction setarchitectures (ISAs), such as the x86, PowerPC, SPARC, or MIPS ISAs, orany other suitable ISA. In multiprocessor systems, each of processors1210 may commonly, but not necessarily, implement the same ISA. Thecomputer system 1200 also includes one or more network communicationdevices (e.g., network interface 1240) for communicating with othersystems and/or components over a communications network (e.g. Internet,LAN, etc.). For example, a client application executing on system 1200may use network interface 1240 to communicate with a server applicationexecuting on a single server or on a cluster of servers that implementone or more of the components of the database systems described herein.In another example, an instance of a server application executing oncomputer system 1200 may use network interface 1240 to communicate withother instances of the server application (or another serverapplication) that may be implemented on other computer systems (e.g.,computer systems 1290).

In the illustrated embodiment, computer system 1200 also includes one ormore persistent storage devices 1260 and/or one or more I/O devices1280. In various embodiments, persistent storage devices 1260 maycorrespond to disk drives, tape drives, solid state memory, other massstorage devices, or any other persistent storage device. Computer system1200 (or a distributed application or operating system operatingthereon) may store instructions and/or data in persistent storagedevices 1260, as desired, and may retrieve the stored instruction and/ordata as needed. For example, in some embodiments, computer system 1200may host a storage system server node, and persistent storage 1260 mayinclude the SSDs attached to that server node.

Computer system 1200 includes one or more system memories 1220 that areconfigured to store instructions and data accessible by processor(s)1210. In various embodiments, system memories 1220 may be implementedusing any suitable memory technology, (e.g., one or more of cache,static random access memory (SRAM), DRAM, RDRAM, EDO RAM, DDR 10 RAM,synchronous dynamic RAM (SDRAM), Rambus RAM, EEPROM,non-volatile/Flash-type memory, or any other type of memory). Systemmemory 1220 may contain program instructions 1225 that are executable byprocessor(s) 1210 to implement the methods and techniques describedherein. In various embodiments, program instructions 1225 may be encodedin platform native binary, any interpreted language such as Java™byte-code, or in any other language such as C/C++, Java™, etc., or inany combination thereof. For example, in the illustrated embodiment,program instructions 1225 include program instructions executable toimplement the functionality of a database engine head node of a databasetier, or one of a plurality of storage nodes of a separate distributedstorage system that stores databases and associated metadata on behalfof clients of the database tier, in different embodiments. In someembodiments, program instructions 1225 may implement multiple separateclients, server nodes, and/or other components.

In some embodiments, program instructions 1225 may include instructionsexecutable to implement an operating system (not shown), which may beany of various operating systems, such as UNIX, LINUX, Solaris™, MacOS™,Windows™, etc. Any or all of program instructions 1225 may be providedas a computer program product, or software, that may include anon-transitory computer-readable storage medium having stored thereoninstructions, which may be used to program a computer system (or otherelectronic devices) to perform a process according to variousembodiments. A non-transitory computer-readable storage medium mayinclude any mechanism for storing information in a form (e.g., software,processing application) readable by a machine (e.g., a computer).Generally speaking, a non-transitory computer-accessible medium mayinclude computer-readable storage media or memory media such as magneticor optical media, e.g., disk or DVD/CD-ROM coupled to computer system1200 via I/O interface 1230. A non-transitory computer-readable storagemedium may also include any volatile or non-volatile media such as RAM(e.g. SDRAM, DDR SDRAM, RDRAM, SRAM, etc.), ROM, etc., that may beincluded in some embodiments of computer system 1200 as system memory1220 or another type of memory. In other embodiments, programinstructions may be communicated using optical, acoustical or other formof propagated signal (e.g., carrier waves, infrared signals, digitalsignals, etc.) conveyed via a communication medium such as a networkand/or a wireless link, such as may be implemented via network interface1240.

In some embodiments, system memory 1220 may include data store 1245,which may be configured as described herein. For example, theinformation described herein as being stored by the database tier (e.g.,on a database engine head node), such as a transaction log, an undo log,cached page data, or other information used in performing the functionsof the database tiers described herein may be stored in data store 1245or in another portion of system memory 1220 on one or more nodes, inpersistent storage 1260, and/or on one or more remote storage devices1270, at different times and in various embodiments. Similarly, theinformation described herein as being stored by the storage tier (e.g.,redo log records, coalesced data pages, and/or other information used inperforming the functions of the distributed storage systems describedherein) may be stored in data store 1245 or in another portion of systemmemory 1220 on one or more nodes, in persistent storage 1260, and/or onone or more remote storage devices 1270, at different times and invarious embodiments. In general, system memory 1220 (e.g., data store1245 within system memory 1220), persistent storage 1260, and/or remotestorage 1270 may store data blocks, replicas of data blocks, metadataassociated with data blocks and/or their state, database configurationinformation, and/or any other information usable in implementing themethods and techniques described herein.

In one embodiment, I/O interface 1230 may be configured to coordinateI/O traffic between processor 1210, system memory 1220 and anyperipheral devices in the system, including through network interface1240 or other peripheral interfaces. In some embodiments, I/O interface1230 may perform any necessary protocol, timing or other datatransformations to convert data signals from one component (e.g., systemmemory 1220) into a format suitable for use by another component (e.g.,processor 1210). In some embodiments, I/O interface 1230 may includesupport for devices attached through various types of peripheral buses,such as a variant of the Peripheral Component Interconnect (PCI) busstandard or the Universal Serial Bus (USB) standard, for example. Insome embodiments, the function of I/O interface 1230 may be split intotwo or more separate components, such as a north bridge and a southbridge, for example. Also, in some embodiments, some or all of thefunctionality of I/O interface 1230, such as an interface to systemmemory 1220, may be incorporated directly into processor 1210.

Network interface 1240 may be configured to allow data to be exchangedbetween computer system 1200 and other devices attached to a network,such as other computer systems 1290 (which may implement one or morestorage system server nodes, database engine head nodes, and/or clientsof the database systems described herein), for example. In addition,network interface 1240 may be configured to allow communication betweencomputer system 1200 and various I/O devices 1250 and/or remote storage1270. Input/output devices 1250 may, in some embodiments, include one ormore display terminals, keyboards, keypads, touchpads, scanning devices,voice or optical recognition devices, or any other devices suitable forentering or retrieving data by one or more computer systems 1200.Multiple input/output devices 1250 may be present in computer system1200 or may be distributed on various nodes of a distributed system thatincludes computer system 1200. In some embodiments, similar input/outputdevices may be separate from computer system 1200 and may interact withone or more nodes of a distributed system that includes computer system1200 through a wired or wireless connection, such as over networkinterface 1240. Network interface 1240 may commonly support one or morewireless networking protocols (e.g., Wi-Fi/IEEE 802.11, or anotherwireless networking standard). However, in various embodiments, networkinterface 1240 may support communication via any suitable wired orwireless general data networks, such as other types of Ethernetnetworks, for example. Additionally, network interface 1240 may supportcommunication via telecommunications/telephony networks such as analogvoice networks or digital fiber communications networks, via storagearea networks such as Fibre Channel SANs, or via any other suitable typeof network and/or protocol. In various embodiments, computer system 1200may include more, fewer, or different components than those illustratedin FIG. 12 (e.g., displays, video cards, audio cards, peripheraldevices, other network interfaces such as an ATM interface, an Ethernetinterface, a Frame Relay interface, etc.)

It is noted that any of the distributed system embodiments describedherein, or any of their components, may be implemented as one or morenetwork-based services. For example, a database engine head node withinthe database tier of a database system may present database servicesand/or other types of data storage services that employ the distributedstorage systems described herein to clients as network-based services.In some embodiments, a network-based service may be implemented by asoftware and/or hardware system designed to support interoperablemachine-to-machine interaction over a network. A network-based servicemay have an interface described in a machine-processable format, such asthe Web Services Description Language (WSDL). Other systems may interactwith the network-based service in a manner prescribed by the descriptionof the network-based service's interface. For example, the network-basedservice may define various operations that other systems may invoke, andmay define a particular application programming interface (API) to whichother systems may be expected to conform when requesting the variousoperations.

In various embodiments, a network-based service may be requested orinvoked through the use of a message that includes parameters and/ordata associated with the network-based services request. Such a messagemay be formatted according to a particular markup language such asExtensible Markup Language (XML), and/or may be encapsulated using aprotocol such as Simple Object Access Protocol (SOAP). To perform anetwork-based services request, a network-based services client mayassemble a message including the request and convey the message to anaddressable endpoint (e.g., a Uniform Resource Locator (URL))corresponding to the network-based service, using an Internet-basedapplication layer transfer protocol such as Hypertext Transfer Protocol(HTTP).

In some embodiments, network-based services may be implemented usingRepresentational State Transfer (“RESTful”) techniques rather thanmessage-based techniques. For example, a network-based serviceimplemented according to a RESTful technique may be invoked throughparameters included within an HTTP method such as PUT, GET, or DELETE,rather than encapsulated within a SOAP message.

Although the embodiments above have been described in considerabledetail, numerous variations and modifications may be made as wouldbecome apparent to those skilled in the art once the above disclosure isfully appreciated. It is intended that the following claims beinterpreted to embrace all such modifications and changes and,accordingly, the above description to be regarded in an illustrativerather than a restrictive sense.

What is claimed is:
 1. A system, comprising: a network interface; anon-volatile storage device; at least one processor; and a memory, thatstores program instructions that when executed by the at least oneprocessor causes the at least one processor to: responsive to receivingindividual ones of a plurality of log records from a storage client viathe network interface and storing the individual ones of the pluralityof log records in an unordered portion of a log in the non-volatilestorage device, send respective storage acknowledgements of theindividual ones of the plurality of log records to the storage client;wherein log records stored in the log describe updates to data stored ina data store, wherein at least one of the log records is storedout-of-order with respect to a log record sequence for the log; andsubsequent to the sending of at least one of the storageacknowledgments, update an ordered portion of the log to store anordered version of one or more of the log records from the unorderedportion of the log including the at least one log record.
 2. The systemof claim 1, wherein to update the ordered portion of the log to storethe ordered version of the one or more log records from the unorderedportion of the log, the program instructions cause the at least oneprocessor to update an index for the ordered portion of the log toidentify one or more data blocks that store the ordered version of theone or more log records.
 3. The system of claim 2, wherein the programinstructions further cause the at least one processor to update an indexfor the unordered portion of the log as the log records are stored inthe unordered portion of the log to identify respective storagelocations for the log records in the unordered portion of the log; andwherein to update the ordered portion of the log to store the orderedversion of the one or more log records from the unordered portion of thelog further the program instructions cause the at least one processor toevaluate the index for the unordered portion of the log to identify theone or more log records to be stored in the ordered portion of the log.4. The system of claim 1, wherein to update the ordered portion of thelog to store the ordered version of the one or more log records from theunordered portion of the log, the program instructions cause the atleast one processor to generate the ordered version of the one or morelog records according to a compression technique.
 5. The system of claim1, wherein the program instructions further cause the at least oneprocessor to determine that a number of log records in the unorderedportion of the log linked in a dependency chain exceeds a coalescethreshold; wherein the update to the ordered portion of the log isperformed in response to the determination that the number of logrecords in the unordered portion of the log linked in the dependencychain exceeds the coalesce threshold; and wherein to update the orderedportion of the log to store the ordered version of the one or more logrecords from the unordered portion of the log, the program instructionscause the at least one processor to coalesce the log records linked inthe dependency chain into a single log record to include as part of theordered version of the one or more log records.
 6. The system of claim1, wherein the system is a storage node of a network-based distributedstorage service, and wherein the storage client is a network-baseddatabase service configured to access the data stored for a database. 7.A method, comprising: performing, by one or more computing devices:responsive to receiving individual ones of a plurality of log recordsfrom a storage client and storing in an unordered portion of a log,sending respective storage acknowledgements of the individual ones ofthe plurality of log records to the storage client; wherein log recordsstored in the log describe updates to data stored in a data store,wherein at least one of the log records is stored out-of-order withrespect to a log record sequence for the log; and subsequent to sendingthe storage acknowledgments, updating an ordered portion of the log tostore an ordered version of one or more of the log records from theunordered portion of the log including the at least one log record. 8.The method of claim 7, wherein updating the ordered portion of the logto store the ordered version of the one or more log records from theunordered portion of the log comprises updating an index for the orderedportion of the log to identify one or more data blocks that store theordered version of the one or more log records.
 9. The method of claim8, wherein the method further comprises updating an index for theunordered portion of the log as the log records are stored in theunordered portion of the log to identify respective storage locationsfor the log records in the unordered portion of the log; and whereinupdating the ordered portion of the log to store the ordered version ofthe one or more log records from the unordered portion of the logfurther comprises evaluating the index for the unordered portion of thelog to identify the one or more log records to be stored in the orderedportion of the log.
 10. The method of claim 7, wherein updating theordered portion of the log to store the ordered version of the one ormore log records from the unordered portion of the log comprisesgenerating the ordered version of the one or more log records accordingto a compression technique.
 11. The method of claim 7, wherein themethod further comprises determining that a number of log records in theunordered portion of the log linked in a dependency chain exceeds acoalesce threshold; wherein the updating the ordered portion of the logis performed in response to determining that the number of log recordsin the unordered portion of the log linked in the dependency chainexceeds the coalesce threshold; and wherein updating the ordered portionof the log to store the ordered version of the one or more log recordsfrom the unordered portion of the log comprises coalescing the logrecords linked in the dependency chain into a single log record toinclude as part of the ordered version of the one or more log records.12. The method of claim 7, wherein the acknowledging and the updatingare performed by a storage node of a network-based distributed storageservice, and wherein the plurality of log records are received from anetwork-based database service configured to access the data stored fora database.
 13. The method of claim 12, further comprising: receiving arequest from another storage node of the network-based distributedstorage service for select log records of the log stored at the storagenode, wherein the select log records include the ordered version of theone or more log records stored in the ordered portion of the log;sending the select log records from the storage node to the otherstorage node; and storing the select log records in an ordered portionof the log maintained at the other storage node.
 14. A non-transitory,computer-readable storage medium, storing program instructions that whenexecuted by one or more computing devices cause the one or morecomputing devices to implement: responsive to receiving individual onesof a plurality of log records from a storage client and storing in anunordered portion of a log, sending respective storage acknowledgementsof the individual ones of the plurality of log records to the storageclient; wherein log records stored in the log describe updates to datastored in a data store, wherein at least one of the log records isstored out-of-order with respect to a log record sequence for the log;and subsequent to sending the respective storage acknowledgments,updating an ordered portion of the log to store an ordered version ofone or more of the log records from the unordered portion of the logincluding the at least one log record.
 15. The non-transitory,computer-readable storage medium of claim 14, wherein, in updating theordered portion of the log to store the ordered version of the one ormore log records from the unordered portion of the log, the programinstructions cause the one or more computing devices to implementupdating an index for the ordered portion of the log to identify one ormore data blocks that store the ordered version of the one or more logrecords.
 16. The non-transitory, computer-readable storage medium ofclaim 15, wherein the program instructions cause the one or morecomputing devices to further implement updating an index for theunordered portion of the log as the log records are stored in theunordered portion of the log to identify respective storage locationsfor the log records in the unordered portion of the log; and wherein, inupdating the ordered portion of the log to store the ordered version ofthe one or more log records from the unordered portion of the logfurther, the program instructions cause the one or more computingdevices to implement evaluating the index for the unordered portion ofthe log to identify the one or more log records to be stored in theordered portion of the log.
 17. The non-transitory, computer-readablestorage medium of claim 14, wherein, in updating the ordered portion ofthe log to store the ordered version of the one or more log records fromthe unordered portion of the log, the program instructions cause the oneor more computing devices to implement generating the ordered version ofthe one or more log records according to a compression technique. 18.The non-transitory, computer-readable storage medium of claim 14,wherein the program instructions cause the one or more computing devicesto further implement determining that a number of log records in theunordered portion of the log linked in a dependency chain exceeds acoalesce threshold; wherein the updating the ordered portion of the logis performed in response to determining that the number of log recordsin the unordered portion of the log linked in the dependency chainexceeds the coalesce threshold; and wherein, in updating the orderedportion of the log to store the ordered version of the one or more logrecords from the unordered portion of the log, the program instructionscause the one or more computing devices to implement coalescing the logrecords linked in the dependency chain into a single log record toinclude as part of the ordered version of the one or more log records.19. The non-transitory, computer-readable storage medium of claim 14,wherein the acknowledging and the updating are performed by a storagenode of a network-based distributed storage service, and wherein theplurality of log records are received from a network-based databaseservice configured to access the data stored for a database.
 20. Thenon-transitory, computer-readable storage medium of claim 19, whereinthe program instructions cause the one or more computing devices tofurther implement: receiving a request from another storage node of thenetwork-based distributed storage service for select log records of thelog stored at the storage node, wherein the select log records includethe ordered version of the one or more log records stored in the orderedportion of the log; sending the select log records from the storage nodeto the other storage node; and storing the select log records in anordered portion of the log maintained at the other storage node.